Jeremy Corbyn has said Labour's win in the Oldham West and Royton by-election shows its strength and the appeal of its anti-austerity message.
Visiting the constituency, Labour's leader hailed an "incredible" result.
His candidate Jim McMahon secured a 10,722-vote majority over UKIP's John Bickley, and a 62% vote share that was higher than at the general election.
UKIP leader Nigel Farage is to make a formal complaint about the vote, claiming there was electoral fraud.
People were turning up with "bundles of postal votes", he told the BBC.
The by-election was triggered by the death of long-serving Labour MP Michael Meacher, who won the seat at May's general election with a 14,738 majority. Mr McMahon said he had "delivered a result that Michael would be proud of".
Labour's total majority was lower this time around but the party ended up with a higher vote share as the turnout - just over 40% - was lower than at May's poll.
The by-election - the first of this Parliament - was also the first major electoral test for Mr Corbyn, who was overwhelmingly elected by Labour members in September but has since faced criticism from some of his MPs - which culminated in a major rebellion over Syria on Wednesday.
Appearing at a rally in the constituency to congratulate Mr McMahon, Mr Corbyn said the victory showed how "strong, deep-rooted and broad" the support was for Labour "not just in Oldham but across the country".
Labour, he said, was "driving the Tories back" and challenging "their austerity agenda and narrative".
Labour's Deputy Leader Tom Watson told the BBC that the result was "very, very good" for Mr Corbyn and urged MPs to "swing behind" their leader after what he said was a "difficult week" for the party.
Mr Watson dismissed UKIP's claims about electoral fraud, saying they sounded like "sour grapes" and if their opponents had an evidence of wrongdoing, they should pass them onto the police.
By Brian Wheeler, political reporter
Reports from the campaign trail in Oldham had suggested Labour was haemorrhaging votes among its traditional white working class supporters, horrified by what one commentator called the party's transformation into a "poncified" party of middle class Metropolitan liberals.
This fed directly into Labour fears that their vote in their traditional English strongholds is as brittle as it proved to be in Scotland.
And that UKIP, with its tough line on immigration and appeal to patriotic values, was poised to replace it.
The London-based away-day pundits have been proved wrong, however.
However, Mr Farage raised claims that the postal vote was rigged, telling the BBC there were "stories of things that shouldn't have been happening" - including claims people turned up at polling stations with multiple postal votes.
"We will file a formal complaint about the abuses that our people saw yesterday," he told Today.
He said they had seen some boxes where 99% of the votes were for Labour, suggesting some members of the Asian population had voted for Labour even though they did not speak English and "did not know who Jeremy Corbyn is".
"It means effectively - in some of these seats where people don't speak English, but they're signed up to postal votes - effectively the electoral process is now dead."
UKIP, which has been targeting Labour's vote in its northern strongholds, had hoped to make the by-election a close-fought contest.
But the outcome was clear early in the evening and Labour activists cheered their candidate when he arrived at Oldham's Queen Elizabeth Hall for the count.
Mr McMahon, 35, is the leader of Oldham Council and Labour's most senior representative in the Local Government Association. Mr McMahon, who is regarded as being a centrist within the Labour Party, told reporters it was a "staggering" result for his party.
He added: "I am sick to death of what the Tories are doing to towns like Oldham. The Northern Powerhouse rhetoric is nothing more than a write-off of the north to create a poorhouse."
The Conservatives came third in the by-election, with their vote share down by almost 10%.
The full result
- Jim McMahon (Labour) - 17,209 (62.11%)
- John Bickley (UKIP) - 6,487 (23.41%)
- James Daly (Conservative) - 2,596 (9.37%)
- Jane Brophy (Liberal Democrat) - 1,024 (3.70%)
- Simeon Hart (Green Party) - 249 (0.90%)
- Sir Oink A-Lot (Monster Raving Loony) - 141 (0.51%)