Jeremy Corbyn appears to have survived a mauling from voters in his first major electoral test as Labour leader, after victory for Sadiq Khan in the London mayoral contest gave a positive spin to an otherwise dismal set of results for the party.

As Labour crashed into third place in the Scottish Parliament, lost its overall majority in the Welsh Assembly and became the first opposition in three decades not to gain council seats in a poll of this kind, Mr Corbyn's performance was openly criticised by a number of his MPs.

Shadow cabinet member Ian Murray warned that voters do not see the party as a credible party of government under his leadership, while veteran backbencher David Winnick said he should consider his position.

But there appeared to be little mood among Labour MPs for an immediate move against Mr Corbyn, and the leader himself said the party had "hung on" and he would be "carrying on".

Mr Khan forged what seemed to be an unassailable lead in the first round of voting in London, scooping 44% of first preference votes, to 35% for his Conservative rival Zac Goldsmith. Final confirmation of the result, delayed until midnight or later by "discrepancies" in the count, showed that after redistribution of second preferences, Mr Khan had garnered 57% support.

In his victory speech, Mr Khan said he never imagined that someone like him, the son of an immigrant who had grown up on a council estate, could be elected mayor.

He pledged to be "a mayor for all Londoners" and in a reference to the controversial campaign against him said that London has chosen "hope over fear and unity over division".

The Labour MP's victory in the fractious contest to succeed Boris Johnson at City Hall was a rare bright moment for Mr Corbyn as "super Thursday" results rolled in.

The Labour leader jumped the gun to publicly congratulate Mr Khan before official results were announced, saying: "Can't wait to work with you to create a London that is fair for all."

With votes continuing to be counted into the weekend, here are the key results:

:: Labour lost 13 Scottish Parliament seats, including 11 to the SNP and two to the Conservatives, although Nicola Sturgeon's nationalists lost their overall majority.

:: In Wales, Labour lost its overall majority in the Assembly, with the totemic Rhondda seat falling to Plaid Cymru leader Leanne Wood.

:: In England, Labour lost control of Dudley Council in the West Midlands, but held on to major cities including Birmingham, Newcastle upon Tyne and Sunderland, as well as key southern outposts such as Exeter, Southampton, Crawley and Slough.

:: With results in from 117 out of 124 councils, Labour was down by 18 seats, the Conservatives down 25, Ukip up 25 and the Lib Dems up 32.

:: The Conservatives lost overall control of Worcester but secured an absolute majority in Peterborough.

:: Ukip secured its first representation in the Welsh Assembly, and added seats on councils including Thurrock, Tamworth and Bolton, but its gains were well short of the triple-figure advances made in similar polls over the past three years.

Speaking during a visit to Sheffield, where Labour held on to a safe Westminster seat in a by-election, a smiling Mr Corbyn said: "All across England last night we were getting predictions that we were going to lose councils. We didn't. We hung on and we grew support in a lot of places."

But Mr Murray - Labour's only MP in Scotland - reflected deep unhappiness among MPs opposed to their leader's left-wing agenda when he told the BBC: "I don't think that the public see the UK Labour Party led by Jeremy Corbyn at the moment as being a credible party of future government in 2020."

Veteran backbencher Mr Winnick called on Mr Corbyn to consider his position in order to give the party a chance of regaining power at the general election.

"The party faces a crisis and the onus is on Jeremy himself. He should decide whether his leadership is helping or hindering the party," he told the Press Association. "I think all the evidence shows that it is not helping."

Union boss Tim Roache, general secretary of the GMB, said Labour should have been winning hundreds of seats at this stage in the electoral cycle, and gave Mr Corbyn "a year or so" to prove himself.

Mr Corbyn's position was bolstered by Labour's influential deputy leader, Tom Watson, who urged critics to show "patience".

"I think even our opponents who are not members of the Labour Party would say that after eight months it would be very unfair and improper, actually, to hang this set of election results on Jeremy Corbyn's peg alone," he told BBC Radio 4's Today programme.

With the overwhelming majority of grassroots members still strongly behind the leader, his close ally, shadow chancellor John McDonnell, said it was time for the "begrudgers" in the party to "put up or shut up".

Allies of the Labour leader took some comfort from a BBC projection which showed the party narrowly ahead in the share of the national vote - with 31% compared with 30% for the Conservatives - but critics said they should be making big gains if they were to go on and win in 2020.

A jubilant David Cameron hailed a "realignment" in Scottish politics after Ruth Davidson led the Tories to a "historic" result that means the party is now the main opposition to the SNP in Holyrood.

During a visit to Peterborough, the Prime Minister said Labour had "completely lost touch" with the working people it was supposed to represent.

"They are so obsessed with their left-wing causes and unworkable economic policies, they've forgotten that people want jobs, people want livelihoods, people want lower taxes, people want homes they live in and can afford to own," he said.