Mr Miliband said it was not the full agreement he wanted
The UK's climate change secretary has said the UN Copenhagen summit was the "most chaotic show on earth" and arguments "strangled" negotiations.
Ed Miliband said he was disappointed China and India did not want legally binding targets, and Sudan and Venezuela almost overturned the accord.
Delegates largely backed a US-led climate deal which included limiting temperature rises to less than 2C.
But the 193-nation summit ended with delegates taking "note" of the deal.
The accord, reached between the US, China and a small group of other countries, was recognised by delegates on Saturday afternoon.
The UN Secretary General Ban Ki-moon said the agreement must be made legally binding next year.
The pact did not win unanimous support, amid opposition from some developing nations.
Mr Miliband said "sticking points" had led four or five countries to almost "dump the agreement completely" at 4am on Saturday morning.
He said he had been in his hotel room, "in his underwear", when he was called back for "hours of wrangling" to stop a deal being blocked.
"The whole accord was in danger of being overturned by some countries, including Sudan and Venezuela.
"I was told that actually the deal looked like it might be just blocked. The Sudanese delegate in particular had compared the deal to the holocaust and was trying to whip up anger against it.
"Luckily we found a way round the issue, but it highlights the complexity of a deal when it needs unanimity," he said.
He said some developing countries, such as China, did not want targets to be under international legally-binding obligations.
"They have doubts about whether we should, as a world, commit to a kind of bigger target, to say, for example - as the scientists say - we should cut our carbon emissions by 50% by 2050."
But he said talks had not been "a waste of time" because it was the first time both developed and developing countries wanted to tackle the problem.
There was also "importantly, finance in the deal", he said.
The agreement outlined a goal of providing $100bn a year by 2020 to help poorer countries and also promised to deliver $30bn (£18.5bn) of aid for developing nations over the next three years.
Mr Miliband said there would be more transparency in about six weeks, when countries had agreed to put forward their targets.
He said he had "absolutely not given up hope, but it was important to move forward urgently" and a legal agreement "was still necessary".
Developed countries also needed to raise their ambition in terms of targets, he said.
Liberal Democrat energy spokesman Simon Hughes said the declaration was "desperately disappointing" when the world needed a deal.
He said: "I can't remember an occasion when more people of power and influence came together on a more important issue and went away with so little to show for it."
Shadow climate change secretary Greg Clark said talks must go on in the months ahead until a proper deal is struck.
He said: "I made it clear in Copenhagen that, if negotiations continue beyond the general election and Conservatives were in government, there would be no let up in our determination to secure a rigorous global deal."
Green Party leader Caroline Lucas said the outcome after years of waiting was "a complete disaster".
She said: "What have we got? An empty accord with no legally binding framework, no targets, and no money guaranteed to be over and above existing aid budgets. It's deeply, deeply disappointing."
Friends of the Earth campaigner Tom Picken said the UK government had said it would fight for a "strong and fair agreement" but the accord was neither.
"It is not even an agreement," he said.
"The parties rejected it as being a consensus decision."
He accused the US of "arm twisting" some countries into a deal, and said the rich countries had acted against the spirit of the past two years of negotiations.