"I believe that Britain needed a Labour government," he said in central London. "I still do, but the British public decided otherwise. I take total responsibility.
"I am so sorry to all of those colleagues who lost their seats."
Despite going into election day with the polls neck and neck, Miliband's party failed to make the expected gains from the Conservatives and lost almost all its Scottish seats to the SNP.
He urged Labour supporters to stick with the party, saying: "I'm truly sorry I did not succeed, I've done my best for nearly five years. This party will come back again."
And in tribute to his online fandom of teenage girls, first identified by BuzzFeed News, he said: "Thank you for the selfies … Thank you for the most unlikely cult of the 21st century – the #Milifandom."
Miliband, who beat his brother David to the leadership in 2010, was dogged by poor personal ratings throughout his time in the job, but enjoyed a late surge during the election campaign that gave Labour supporters hope he could win.
Miliband said he would step down immediately to allow a leadership election to take place.
Jim Waterson is a politics editor for BuzzFeed News and is based in London.
Contact Jim Waterson at email@example.com.
Got a confidential tip? Submit it here.