Sadiq Khan has been chosen as Labour candidate to run for London mayor in 2016.
The human rights lawyer and MP for Tooting pipped former Olympics minister Tessa Jowell in an alternative vote system which went to five rounds.
The former shadow justice secretary had won strong support from trade unions in his battle to be elected as successor to Boris Johnson at City Hall, and was endorsed by Unite and the GMB.
Accepting his nomination at London's Festival Hall, a tieless Mr Khan promised: "Together we can build a fairer city, a healthier city and, importantly, a city of opportunity.
"I will repay the faith so many have placed in me today. I will devote all my energies in our campaign to win back City Hall - winning for a purpose. I will stand by the values so many of us share - fairness, ambition and opportunity.
"Together we can make a difference. Together we can fight for all Londoners. Together we can win. Together we can change London."
Paul Maloney, regional secretary of the GMB union said: "This is a convincing win for Sadiq. We now want to see all parts of the party uniting to secure a win in the election next year."
Peter Kavanagh, Unite's London and south east regional secretary, said: "The selection of Sadiq Khan to be Labour's mayoral candidate is a vindication of the progressive polices he set out during the campaign.
"On housing, transport and employment Sadiq offered a positive vision that will deliver the change Londoners are crying out for and with Sadiq as Labour's candidate I am sure we will win."
Mr Khan, 44, entered Parliament in 2005 and took ministerial posts in the communities and transport departments under Gordon Brown. He was appointed to Ed Miliband's shadow cabinet as shadow justice secretary and shadow lord chancellor in 2010, but quit following this year's general election defeat to pursue the mayoral nomination.
He is the first major party candidate to be formally named, though the Liberal Democrats are shortly expected to confirm their nomination of Caroline Pidgeon from a shortlist of one. Sian Berry has been chosen as Green contender, while the Conservatives are due to announce their choice from a shortlist of four - including millionaire MP and environmentalist Zac Goldsmith - by the end of the month.
Bookmakers William Hill immediately installed Mr Khan as 8/11 favourite to be next London mayor, ahead of Mr Goldsmith on 11/10.
Mr Khan took 58.9% of the vote, against Baroness Jowell's 41.1% in the final round of counting, after the second preferences of other candidates were redistributed.
First to be eliminated, after receiving the fewest of the 87,954 votes cast, was Harrow MP former international development minister Gareth Thomas, followed by transport campaigner Christian Wolmar, Tottenham MP David Lammy and left-wing former public health minister Diane Abbott.
In the final round, Mr Khan took 48,152 votes to Lady Jowell's 33,573.
He said he was "overwhelmed and deeply humbled that so many Londoners have put their faith in me today", adding: "I'm determined to repay your faith by winning the mayoral election next May and making a real difference to Londoners' lives."
Mr Khan said: "I love this city. It's given me and my family huge opportunities. My dad was a bus-driver and my mum sewed clothes to help support our family.
"We lived on a council estate in south London, my mum, my dad, my brothers and my sister. City Hall might have been a few stops up the Northern Line, but to a young Londoner like me it seemed a million miles away.
"To many young Londoners today, it still feels a million miles away.
"I never dreamed that I would be standing here as your candidate for mayor and I'm only here because of the opportunities London gave me and my family - a safe and affordable council home, so my parents could save for a home of their own; a fantastic state school education for me and my brothers and sister; university education based on the grades we had rather than our means."
He said his campaign would be underpinned by the "burning ambition" to ensure all Londoners have similar opportunities in future, to make London the best city in the world to start a business and to be "the greenest mayor we've ever had" and freeze transport fares while investing in the network.
Following the result, Ms Abbott congratulated Mr Khan, adding: "All of us in Labour will be backing his campaign to be elected mayor in May 2016.
"I'm pleased that most of my supporters transferred their votes to Sadiq.
"Labour beat the Tories in London this May. Now with large numbers of new members and supporters we aim to defeat the Tories, to ensure London government changes and works for all."
Mr Khan's victory over the Blairite Lady Jowell was widely seen as a pointer towards possible victory for left-winger Jeremy Corbyn in the election for party leader.
The Tooting MP nominated Mr Corbyn to help him enter the leadership race, though he said that he had actually voted for Andy Burnham as leader.
Mr Corbyn welcomed the result with a message on Twitter: "Congratulations Sadiq Khan for becoming London's Labour mayoral candidate - regardless of leadership result I look forward to working with him."
But Mr Khan told BBC Radio 4's World At One: "I was very clear when I nominated Jeremy all those months ago that I was going to nominate him because it was really important that the views he held - and many people subscribe to those views - were aired. I made clear when I nominated him that I wouldn't be voting for him.
"My first choice when it came to the leadership elections went to Andy Burnham.
"What's important is that, whoever the Labour movement decide to select as our leader tomorrow, we as a party need to get behind him or her."
Speaking to journalists after the announcement at the Royal Festival Hall, Mr Khan said he had always believed he would win comfortably.
"I never thought it was going to be a close race. I was always quietly confident," he said.
Asked whether backing from former London mayor Ken Livingstone had swung the result for him, Mr Khan said: "I've been blessed by having all kinds of endorsements from sorts of great people, Ken Livingstone, Margaret Hodge, Oona King, Michael Cashman.
"I am not tribal. If you see the people who are supporting me it is across the Labour spectrum.
"What I am pleased about is that I have won every single section of the vote - members, supporters, affiliated and registered as well.
Mr Khan praised Baroness Jowell as a "formidable politician" - but declined to say whether he would offer her a job if he won the mayoralty.
The Tooting MP signalled he would not hesitate to take different positions to the new Labour leader - widely expected to be left-winger Mr Corbyn.
Mr Khan nominated Mr Corbyn for the contest to widen the debate, but made clear he did not agree with his policies.
"We will wait and see what happens tomorrow. Let's not predict ... but whoever the Labour leader is, the candidate for mayor has got to have a relationship with them," he said.
"The number one issue for me is making sure I am London's advocate, and on the side of London.
"Sometimes that may mean there being tension between me and the Labour leadership. Other times we will be probably on the same side."
He confirmed that, if elected mayor next year, he would stand down as MP for Tooting.
"Being mayor of London is a full-time job, so much as I love Tooting ... I don't think it is possible to be a member of parliament and a mayor at the same time," Mr Khan said.