Labour have won the Barnsley Central by-election, while the Lib Dems slipped to sixth in the South Yorkshire seat.
UKIP, the Conservatives, the BNP and an independent all finished ahead of the Lib Dems, who came second in the seat in last May's general election.
Winning candidate Dan Jarvis said it sent a message to the coalition but Lib Dem leader Nick Clegg said people should not "write off" the party.
UKIP reacted to coming second by saying they were "the winners" in the poll.
The by-election was caused by the conviction of former Labour MP Eric Illsley for dishonestly claiming parliamentary expenses.
Illsley - who quit as an MP in January - held Barnsley Central with a majority of just over 11,000 in last year's general election and 47% of the vote, with the Liberal Democrats in second place.
But the MP resigned his seat after pleading guilty to falsely claiming £14,000 in parliamentary expenses. He was later jailed for a year.
Labour got 14,724 votes in the by-election, extending their majority slightly to 11,771, but the turnout fell to 36.5%, compared with 56.4% at the last general election.
Labour took 60.8% of the vote, UKIP's Jane Collins 12.19%, the Conservatives' James Hockney 8.25%, the BNP's Enis Dalton 6.04%, Independent Tony Devoy 5.23% and the Liberal Democrats' Dominic Carman 4.18%.
Mr Carman lost his deposit as the party's share of the vote fell from 17.2% in the 2010 general election to 4.1%. He said: "The voters here in Barnsley have given me and the Liberal Democrats a kicking. We can take it."
Reacting to the result, Mr Clegg said there had been an "abysmally" low turnout and all the parties had been left to "pick up the pieces".
He told Sky News that he had no doubt people would seek to "write off" the Lib Dems on the basis of a single result.
"We have proved them wrong in the past and we will prove them wrong again," he said, adding that the party was committed to continuing to work hard to clear up the "economic mess" the government had inherited.
Mr Jarvis, a 38-year-old former soldier who served in Afghanistan and Iraq, said the people of Barnsley Central were sending the "strongest possible message" to David Cameron and Nick Clegg.
"Your reckless policies, your broken promises and unfair cuts are letting our country down," he said.
"I grew up in Margaret Thatcher's Britain. I remember how angry it made me feel. Whole communities abandoned to unemployment, public services run down, talents wasted, opportunities taken away.
"Thatcher was wrong then and Cameron is wrong now."
UKIP leader Nigel Farage welcomed the party's performance - which saw it nearly double its share of the vote. "We are the winners tonight," he said. "We have come from nowhere to come second in this election."
The by-election is only the second since the coalition government took power last May, the other being January's contest for Oldham East and Saddleworth which Labour also won comfortably.
BBC political correspondent Ross Hawkins said the result would be a real concern for the Lib Dems ahead of May's English council elections although it remained to be seen whether the slump in their support was a one-off or a sign of a wider trend.