Sadiq Khan has been elected the new Mayor of London — boosting Labour after it slumped in Scotland's elections.
Mr Khan is the city's first Muslim mayor, after beating Tory Zac Goldsmith by 1, 310,143 votes to 994,614.
The result bolsters leader Jeremy Corbyn after Labour were beaten into third in Scotland by the Tories and lost some English councillors.
In Scotland, the SNP said it would form a minority government after winning its third election in a row.
First Minister Nicola Sturgeon is celebrating what she said was an "emphatic" victory, her first as party leader, after the SNP emerged as the largest party at Holyrood with 63 seats, ahead of the Conservatives on 31 and Labour on 24.
But she played down talk of another independence referendum after falling short by two seats of an overall majority.
In Wales, Labour remains as the largest party, with 29 out of 60 seats, but was denied a majority as Plaid Cymru and UKIP both made notable gains. Counting is continuing in Northern Ireland.
Mr Khan's victory ends eight years of Conservative control of City Hall. The former Labour MP and minister, 45, becomes London's third mayor after Ken Livingstone and Boris Johnson.
In his victory speech, Mr Khan referred to his humble origins on a council estate and said he had never imagined that "someone like me could be elected as mayor of London," promising to be a mayor "for all Londoners".
He said the campaign had not been without controversy, but added: "I am so proud that London has today chosen hope over fear".
He added that the "politics of fear is not welcome in our city".
Mr Khan took 1,310,143 votes after second preferences were taken into account, beating Conservative Zac Goldsmith into second place on 994,614, a margin of victory of 13.6%. His tally gave him the largest personal mandate of any politician in UK history.
Labour leader Jeremy Corbyn led congratulations on Twitter using the hashtag YesWeKhan and telling the new mayor: "Can't wait to work with you to create a London that is fair for all".
Mr Khan distanced himself from Mr Corbyn during the campaign, pledging to freeze fares on the capital's transport network and build more affordable housing, but also promising to champion business and cut taxes on enterprise.
His victory follows a controversial campaign in which the Conservatives were accused of trying to smear Mr Khan by accusing him of sharing a platform with extremists — tactics defended by ministers but questioned by some in the party.
Mr Goldsmith's sister Jemima has criticised how his campaign was run, while former Conservative Cabinet minister Baroness Warsi called it an "appalling dog whistle campaign".
Ms Goldsmith tweeted: "Sad that Zac's campaign did not reflect who I know him to be — an eco friendly, independent-minded politician with integrity."
She also congratulated Mr Khan, calling him a "great example to young Muslims".
David Cameron's former director of strategy Steve Hilton described the Goldsmith campaign as "really weird," claiming it had brought back the "nasty party label to the Conservative Party".
Who is Sadiq Khan?
The new mayor did not have a privileged start in life. He was one of eight children born to Pakistani immigrants, a bus driver and a seamstress, on a south London housing estate.
From an early age, he showed a firm resolve to defy the odds in order to win success for himself and the causes important to him.
That resolve has won him the biggest personal mandate in the UK, a job with wide-ranging powers over London and with enormous emotional significance for him.
Some question whether he has the experience or record of good judgement necessary for the role.
He insists he is there to represent all Londoners and to tackle inequality in the capital, and now he has the chance to prove it.
Outgoing mayor Boris Johnson said: "Many congratulations to Sadiq on securing a huge mandate to do the best job in British politics. I wish him every possible success and will be calling him in the morning.
"I have also been in touch with Zac and thanked him for his heroic efforts to carry the Conservative banner in our city, in spite of the strong headwinds he faced at this stage in the political cycle."
A Labour victory in the capital was seen as a minimum expectation if Mr Corbyn was to avoid a full-blown leadership crisis after the party suffered one of its worst ever results in Scotland — losing 13 seats and being pushed into third place by the resurgent Scottish Conservatives.
Speaking before Mr Khan's victory, Mr Corbyn talked up Labour's performance in Thursday's elections, saying it had defied predictions by retaining control of councils in the south of England such as Southampton, Hastings, Crawley and Norwich.
Jump media playerMedia player help
"All across England last night we were getting predictions that we were going to lose councils," he said on a visit to Sheffield. "We didn't. We hung on and we grew support in a lot of places."
Allies of Mr Corbyn have called on critics within the party to rally round the leader, Shadow Chancellor John McDonnell urging an end to "carping" and shadow environmental minister Clive Lewis said they should "put up or shut up".
But former shadow minister Michael Dugher said Labour was "not on a trajectory to victory" in the next general election, scheduled for 2020, while former shadow chancellor Chris Leslie said Labour should have done much better.
In other election developments:
Former Tory MPs Neil Hamilton and Mark Reckless are among UKIP candidates elected to the Welsh Assembly
UKIP gains English council seats, including six in Thurrock, and comes second in two by-elections
Gill Furniss, the widow of Labour MP Harry Harpham, retains his Sheffield seat in a Westminster by-election
The Lib Dems gain MSPs in Edinburgh and Fife, take control of Watford Council and add 29 councillors
Labour wins seats from the Conservatives on the London Assembly
Liverpool's Labour Mayor Joe Anderson is re-elected
Shadow Home Secretary Andy Burnham considers running for newly created role of Greater Manchester mayor
The Democratic Unionists and Sinn Fein were on course to retain their grip on power at Stormont as the Assembly election count neared its half way point
Ex-Labour MP Vera Baird is re-elected as police and crime commissioner for Northumbria, as the 40 results are declared
Labour's vote share is down about 6% on average on 2012 — the last time these seats in England were contested — with 24 fewer councillors. But its share is up 4% on the general election in key wards, with the Conservatives down by a similar amount.
On the basis of Friday's results, the BBC is calculating that Labour would have got a 31% projected share of the national vote, slightly higher than expected, with the Conservatives on 30%, the Lib Dems on 15% and UKIP on 12%.
In Scotland, Labour gained one seat from the SNP — Edinburgh Southern — but failed to take other targets and was beaten into third place by the Conservatives — a result that would have been unthinkable in the past.
Speaking in Edinburgh, Nicola Sturgeon said the SNP had a "clear and unequivocal" mandate and would govern on its own rather than in alliance with other parties.
On the question of a future vote on independence, she said the SNP would make "its case with passion, with patience but will always respect the opinion of the people".
But Scottish Conservative leader Ruth Davidson, who said any prospect of the issue being reopened in the next five years had been "utterly shredded" by the SNP's failure to win a majority.
In Wales, Labour's vote is down by eight points overall, the Conservative vote is down by three points, while Plaid Cymru is up by two points.
Plaid Cymru leader Leanne Wood celebrated a famous victory after she took the seat of Rhondda from Labour in its south Wales heartlands. The Lib Dem Welsh leader Kirsty Williams resigned after her party was reduced to one seat in the Welsh Assembly.
But the biggest story of the night in Wales was the performance of UKIP, which saw its vote increase by 12 points and saw seven candidates elected.
Thursday's polls were the single largest test of political opinion before the next general election, which is scheduled for 2020, with 43 million people entitled to take part.
In total, 2,747 seats in English councils — spanning metropolitan boroughs, unitary authorities and district councils — were up for grabs.
David Cameron said the party's second place in Scotland and its showing in England, where it took control of Peterborough Council and won council seats in key
Westminster marginals such as Dudley and Nuneaton, represented a good result for a party which had been in government for six years.
Saturday 7 May
14:00 Results from five remaining councils in England
16:00 Result of Bristol Mayoral contest
Result of elections to Northern Ireland Assembly expected
Sunday 8 May
16:00 Result of elections to Bristol Council (final council in England to declare)
Results of Police and Crime Commissioner elections in Wales