Labour have comfortably won the Oldham East and Saddleworth by-election with a majority of more than 3,500.
Debbie Abrahams held off the challenge of Lib Dem Elwyn Watkins, while the Conservatives' vote fell by more than 7,000 as they came a distant third.
Labour leader Ed Miliband said it sent a "clear message" to ministers about rising VAT, tuition fees and cuts.
Nick Clegg said he was pleased with the Lib Dem performance, their share of the vote was slightly up on May's result.
The by-election was called after a special court found ex-Labour minister Phil Woolas had lied about Mr Watkins in May's general election and invalidated the result.
Eight months ago, Labour won the seat by just 103 votes from the Lib Dems but, this time, it secured a much clearer victory - finishing 3,558 votes ahead of their closest rivals with 14,718 votes. The party's share of the vote increased from 31.9% to 42%.
Although the Lib Dems failed to snatch the seat, their share of the vote actually increased slightly, from 31.6% at the general election to 31.9%.
They polled 11,160 votes, with the Conservatives getting 4,481 (12.8% share), UKIP 2,029 (5.8%) and the BNP 1,560 (4.5%).
However, the Tories' share of the vote fell from 26.4% in May.
BBC political editor Nick Robinson said Labour and the Lib Dems would be relieved by the result - but it would worry some Conservatives.
The Tory leadership would be pleased their coalition partners had avoided disaster but Tory activists would be anxious about Mr Cameron's apparent willingness to help the Lib Dems and the possible collapse of working class Tory support in northern seats.
The by-election is the first significant opportunity that voters have had to pass judgement on the policies of the coalition government and Ed Miliband's performance as opposition leader.
Senior Labour figures hailed the result as proof of public "anger".
Party leader Ed Miliband said: "I think the voters of Oldham east and Saddleworth have sent a very clear message to the government about some of the things they've been doing, the rise in VAT, the trebling of tuition fees and the police cuts...
"This is the first step in a long journey for Labour. But more importantly, I hope the government will listen to what they've said about those key issues."
Ms Abrahams told Labour activists that the result sent a clear message to David Cameron that "you have to listen, think again and change direction".
But the Conservatives and Lib Dems argued that Labour had held the seat since it was created in 1997.
Lib Dem deputy leader Simon Hughes told the BBC his party was in "good heart".
"We pushed up our share of the vote and actually we had the same share of the vote yesterday as Labour won with at the general election just a few months ago."
Party leader Nick Clegg, who visited the constituency three times to throw his weight behind the party's candidate Elwyn Watkins, said the party had "brought the fight to Labour's front door in a way that will have confounded our critics".
Mr Watkins, whose court battle against Phil Woolas triggered the contest, said he had no regrets: "I think it was the right decision to take and I am proud of what I did."
Turnout in the contest was considerably lower than in the general election, with 48% of registered voters casting their ballots compared with 61% in May.
Conservative Party co-chairman Baroness Warsi said it was "inevitable" that the party which started in third place would see their vote "squeezed" in a by-election.
She denied the Conservatives had deliberately fought a lacklustre campaign to benefit their coalition partners. She told the BBC: "It was resourced properly. We had volunteers on the ground. We had professionals on the ground. We had a great local candidate."
She said the Tories had run a "positive campaign" and while they had not attacked the Lib Dems, they had "never campaigned for them either".
Asked about criticism from the Tory right wing about the campaign, she added: "I would say to those who are critical: 'Unless you were here, unless you were out delivering and unless you were knocking on doors, you really don't have a right to complain about us not being vigorous enough'."
May's result was declared void by three judges and Mr Woolas barred from standing for public office for three years, triggering the first by-election since the coalition government took office.
All the main party leaders visited the constituency during the campaign, the first by-election to take place in January for more than 40 years.
Ten candidates, in total, stood in the contest. UKIP came fourth with 2,029 votes, ahead of the BNP and the Green Party.