"#lilliband lol" wrote Lily next to photo, which quickly earned more than 4,400 likes.
"@LilyAllen Lovely to see you last night!" replied the politician.
The Hard Out Here singer's photo followed in the footsteps of TOWIE star Joey Essex, who also formed an unlikely friendship with David Miliband's brother during the awards.
"With my mate @Ed_Miliband at the #Millies #SELFIE," posted Joey on Twitter, which was then retweeted by 2,200 of Joey's fans, including Mr Miliband himself.
The evening, which honours members of the British armed forces, was inspirational for all involved.
"Meeting amazing people tonight at the #Millies," tweeted Joey, who is fresh from his stint on this year's I'm A Celebrity... Get Me Out Of Here, "@FABMediaOfficer such a Reem Charity."
Helen Flanagan, Mark Wright, Kimberley Walsh and Carol Vorderman also stepped out at the Greenwich Maritime Museum for the awards, as did the Duchess of Cornwall, David and Samantha Cameron and Prince Charles, who founded the awards.
Olympic cyclist Sir Bradley Wiggins presented the night's Overcoming Adversity award to triple amputee Corporal Josh Boggi.