Respect Party candidate George Galloway has taken the Bradford West parliamentary seat from Labour, winning the by-election by 10,140 votes.
Mr Galloway, expelled by Labour in 2003, said it was the "most sensational victory" in by-election history.
Labour leader Ed Miliband said it was "incredibly disappointing" and the party needed to "learn lessons".
At the 2010 General Election, Labour's Marsha Singh, who resigned on health grounds, won with a majority of 5,763 .
The party had held the West Yorkshire seat since 1974, except for a brief period in the 1980s when the sitting MP defected to the SDP.
Mr Galloway won 18,341 votes, a 56% share of the total vote. Labour candidate Imran Hussein came second with 8,201 votes as the party's share of the vote was 20% down on its 2010 figure.
Conservative candidate Jackie Whiteley was third, with 2,746 votes. Jeanette Sunderland, of the Liberal Democrats, secured 1,505 votes - the party lost its deposit.
Mr Galloway, who co-founded the anti-war Respect Party after being expelled by Labour because of comments he made as part of his opposition to the Iraq war, said the result represented the "Bradford Spring".
He said the "mammoth vote" represented a "total rejection" of the three major parties in the British political system.
He said Labour "must stop imagining that working people and poor people have no option but to support them if they hate the Tory and Liberal Democrat coalition partners.
"They have to stop supporting illegal, bloody, costly foreign wars because one of the reasons why they were so decisively defeated this evening is that the public don't believe that they have atoned for their role in the invasion and occupation of other people's countries and the drowning of those countries in blood."
Mr Miliband said the result had been unexpected and the reasons for it were "not simple".
"We should have won this by-election and I am very disappointed we did not," he said.
"I think this was to do with local factors that were particular to the constituency and we have got to understand those lessons."
He said he would travel to Bradford in the near future to start the process of trying to "win back people's trust".
A Liberal Democrat spokesman said the party was "clearly disappointed" with the result while David Ward, Lib Dem MP for Bradford East, said Mr Galloway still spoke for the old Labour Party.
"This was the Asian community within Bradford, really, who are in some ways punishing the Labour Party for abusing them and using them in the past," he said.
But Salma Yaqoob, the Respect Party leader, said it was "patronising" to suggest that Mr Galloway - a critic of the UK's mission in Afghanistan - had been dependent on support from Muslims for his victory.
She told Radio 4's Today programme: "Look at the result...Over 50% of the vote. That is not just one community coming out to vote. That is young, old people, people across all areas. In fact in every area across the constituency, Respect won."
Conservative Party co-chair Baroness Warsi said Mr Galloway had clearly "connected" with the electorate and suggested the result was disastrous for Labour.
"If Ed Miliband can't get his act together after a week like this when is he going to get his act together?" she told BBC Radio 4's Today programme.
"This is a Labour seat, has been for many, many decades and last night they lost it in spectacular fashion."
BBC Yorkshire political editor Len Tingle said there had effectively been two campaigns in the seat - one with the three main UK parties focused on the economy and jobs, and the other run by Mr Galloway which had his party's anti-war message at its forefront.
Turnout in the by-election was just over 50%, compared with 64.9% in the 2010 general election.
Bookmakers said they had taken a lot of money on Mr Galloway in the days leading up to the poll and had slashed the odds on him winning. Ladbrokes said they faced paying out up to £100,000 in winning bets.
It is the second time Mr Galloway has upset the political odds - he pulled off one of the most memorable results of the 2005 General Election when he overturned a large Labour majority in London's Bethnal Green and Bow to become the Respect Party's first MP.
His win in Bradford West is a remarkable comeback after disappointing showings at the 2010 General Election and the 2011 Scottish Parliament elections. With a different candidate, Respect only came fifth in Bradford West in the 2010 General Election.
Labour have won all five previous by-elections in England and Scotland since the 2010 General Election.
The full result (with vote share and change since 2010 in brackets):
George Galloway (Respect) 18,341 (55.89%, +52.83%)
Imran Hussain (Lab) 8,201 (24.99%, -20.36%)
Jackie Whiteley (C) 2,746 (8.37%, -22.78%)
Jeanette Sunderland (LD) 1,505 (4.59%, -7.08%)
Sonja McNally (UKIP) 1,085 (3.31%, +1.31%)
Dawud Islam (Green) 481 (1.47%, -0.85%)
Neil Craig (D Nats) 344 (1.05%)
Howling Laud Hope (Loony) 111 (0.34%)