Jeremy Corbyn has travelled to Newport to congratulate Labour's winning candidate in the parliamentary by-election in the South Wales city.
Ruth Jones won Thursday's contest in Newport West by 1,951 votes over the Conservatives, but saw Labour's share of the poll slump as electors switched to Ukip and other smaller parties.
On a low turnout of 37%, Labour took 9,308 votes to the Tories' 7,357. Ukip's Neil Hamilton came in third with 2,023, followed by Plaid on 1,185 and the Liberal Democrats on 1,088.
The contest was triggered by the death of veteran MP Paul Flynn and came against the backdrop of Brexit battles at Westminster.
Mr Corbyn said the result showed voters who backed both Leave and Remain in the EU referendum uniting behind Labour's "social, economic and political agenda".
Telling Mrs Jones she will make a "brilliant" MP, the Labour leader said: "The people of Newport deserve that and Newport deserves a Labour government to take away the misery of Universal Credit and the poverty and pain and desperation that brings to so many families."
But results showed Labour's share of the vote slump from the 52% secured in 2017 by Mr Flynn – the seat's MP since 1987 – to just 39.6% now.
The Conservatives also dipped – from 39% two years ago to 31.3% – while Ukip saw their vote share surge from 3% to 8.6% and Plaid Cymru, the Lib Dems and Greens all put on more than two points.
Mrs Jones paid tribute to her predecessor in her victory speech, saying: "This by-election has taken place because of the sad passing of Paul Flynn, our friend.
"There have been many tributes to him over the weeks, but one saying stood out to me: 'Everyone knew someone helped by Paul Flynn'. These words have been an inspiration to me during this campaign."
Mrs Jones added: "Who knows what the next few days, weeks and months will bring? But what I do know is that people have had enough after a decade of austerity."
Mr Corbyn joked that, as a physiotherapist, the new MP would be able to help people at Westminster "de-stress", as well as standing up for "our precious National Health Service".
He told her: "You'll be challenging the privatisation of our NHS, you'll be challenging the contracting-out, you'll be challenging what's happening in our NHS."
Newport was a test for Labour's ability to hold on to support in areas which backed EU withdrawal in the referendum.
Long a Labour stronghold, the city voted Leave by a margin of 56% to 44% in 2016, when Mrs Jones campaigned for Remain.
— Jeremy Corbyn (@jeremycorbyn) April 5, 2019
Parties blamed the low turnout – down from 67.5% in the 2017 general election – on anger over the slow progress of Brexit, as well as on poor weather which saw rain and hail in the constituency on Thursday.
Ukip leader in Wales Mr Hamilton, the highest profile name taking part in the contest, sought a return to the Commons more than two decades after being ousted as an MP in the 1997 general election over the cash-for-questions scandal.
Mr Hamilton had hoped to benefit from the Brexit effect, urging voters to send a clear message to Westminster over its handling of the UK's exit from the EU.
The Brexit delay raised the question of "whether the people are the ones the politicians obey or the other way around", he said, adding: "That is an issue that certainly isn't going to go away, and Ukip isn't going to go away."
Mr Hamilton said he regarded the near-quadrupling of Ukip's vote-share as "a success in itself, even though we didn't win the election".
He said: "I regard this as the start of a new era for my party and I look forward to the next election, whenever that may come."
Conservative candidate Matthew Evans, who saw a swing from Labour to the Tories of 2.36%, said he had "never seen such anger" on the doorstep regarding Brexit.
Mr Evans said: "I have never known such anger and frustration, which I share and has been reflected in the turnout. People just want clarity and I've seen no appetite for another referendum or a general election."
Mrs Jones is a former president of the Wales Trade Union Congress (TUC) and was defeated at two previous parliamentary elections for Monmouth in 2015 and 2017 by Conservative David Davies.