By Alex Stevenson and Ian Dunt
Ed Miliband has been elected Labour leader after a gruelling four-and-a-half month campaign.
A dramatic and emotional announcement in Manchester saw the younger sibling win by 50.65% to his brother's 49.35%.
"You have put your trust in me and I am determined to pay that back to you," he said in his victory speech.
"The first way I will repay that trust is by uniting our party and taking it forward together.
"David I love you so much as a brother, and I have such extraordinary respect for the campaign you ran. We all know how much you have to offer this party in the future."
In a development which will be picked over at length in the days to come, he managed to just take the lead at the last minute when the second preference votes of Ed Balls, who came third, were distributed.
But some in the Labour party will be irritated that the candidate who came second in the MP/MEPs' and members' electoral colleges still managed to secure the leadership.
That fact may also be picked over during the forthcoming AV referendum which would expand the same voting system for general elections.
David Cameron offered Mr Miliband his congratulations.
a href="http://www.politics.co.uk/features/opinion-former-index/legal-and-constitutional/comment-ed-miliband-is-more-dangerous-than-they-think-$21384250.htm" target="_blank">
Comment: Ed Miliband is more dangerous than they think
"I was leader of the opposition for four years and know what a demanding but important job it is," he said.
"I wish him and his family well."
In the end, widespread union support saved Ed Miliband from defeat - a fact that will be used to by right-wing media outlets to justify the tag 'Red Ed'.
"My message to the country is this: I know we lost your trust. Today a new generation has taken control of Labour, a new generation that understands the call for change," Ed Miliband continued.
"I believe in Britain. Today's election turns a page because a new generation has stepped forward to serve our party and in time to serve out country. Today, the work of the new generation begins."
The decision will trigger a dramatic realignment of Labour policy.
The party will now adopt a more consistently left-wing perspective on economic issues, including a more cautious response to the deficit reduction plan and tougher action on the banking sector.
The party will also become much more sympathetic towards civil liberty issues, which the winning candidate put front-and-centre of his campaign.
It is likely to adopt a far tougher approach to US-UK relations. Ed Miliband was opposed to the Iraq war and has promoted a more independent foreign policy.
Left-wingers hailed the result. Luton North MP Kelvin Hopkins told politics.co.uk: "We're now into a new era of a united Labour party pursuing more progressive democratic socialist policies.
"We now have a united party behind a new leader who is very much more central to the party's beliefs. And I think that's crucial."
Others were forced to hide their disappointment. One shadow minister who had supported David Miliband suggested both his preferred candidate and Mr Balls had been seen as the candidates of Tony Blair and Gordon Brown.
Jim Murphy, who helped orchestrate David Miliband's campaign, told politics.co.uk: "It was close, but well done to Ed. I think in the Labour party enjoys looking backwards. Ed's won so let's look forwards."
He added: "You can digest or dissect the contest we've just gone through. I'd rather as a team work together to put a plan in place for the election campaign.
The new leader was confirmed this afternoon at an event kickstarting the Labour autumn conference in Manchester this week.
Gordon Brown spoke to the hall before the unveiling of the new leader.
Rumours had persisted since Tony Blair released his memoirs that Mr Brown wanted recognition at the event to make up for the attacks on him in the book.
Speaking about his defeat at the general election, Mr Brown said: "I take the whole fault upon my shoulders alone.
"It's for this party to get out of what were worst at - the blame game - and back into what we're best at - the future business.
"This today I can promise you: if you pick up a newspaper or turn on a television you will not find me, not ever, doing anything other than supporting the Labour team."
Among those watching with interest were Conservative party members. One government insider told politics.co.uk the Tories were "dreading" a victory for the shadow foreign secretary, whose brand of centrist politics they considered more dangerous that the more straightforwardly left-wing rhetoric of his brother.
Speaking to the BBC, Baroness Warsi, Tory party chairman, congratulated Ed Miliband, but insisted that he was "clearly" not the choice of MPs or party members - suggesting the government will focus on Ed Miliband's union support as its chosen avenue of attack.
"There are some very challenging days ahead for Ed Miliband," she warned.
"What would have been quite nice to hear in that speech, was sorry for the part he played as chief special advisor to the Treasury and then as Gordon Brown's advisor for the mess the country was left with by the previous government"
Under the AV rules, no candidate wins until they have secured over 50% of the vote. When a candidate comes last they are knocked out and their second preference votes redistributed to the remaining candidates.
Diane Abbott was knocked out in the first round and Andy Burnham in the second round, at which point David Miliband was still in the lead. By the time Ed Balls was knocked out, his second preference votes took Ed Miliband over the finish line.