Media playback is unsupported on your device Media caption Former Tory MP Douglas Carswell becomes the first UKIP candidate to be elected to the House of Commons

Nigel Farage has predicted UKIP could hold the balance of power following the next general election after his party gained its first elected MP.

The UKIP leader said his party had momentum after Douglas Carswell won the Clacton by-election by 12,404 votes.

In Friday's other by-election result, Labour held on to Heywood and Middleton but UKIP slashed its majority to 617.

David Cameron said voting UKIP helped Labour, while Ed Miliband pledged no "complacency" from his party.

After Mr Carswell overturned a 12,068 Conservative majority in the Essex seat to push his old party into second place, Mr Farage said "something big" was happening in British politics.

Media playback is unsupported on your device Media caption UKIP leader Nigel Farage: "The whole of British politics has been shaken up"

He added: "We've got a chance here in a general election next year that is likely to be very tight, in an election in which no one party is likely to have a majority. If UKIP can keep this momentum going, we could find ourselves next May in a position where we hold the balance of power."

He said UKIP's second place in Heywood and Middleton was "even more significant" than its win in Clacton, saying the party was now the main opposition to Labour in northern cities.

Mr Farage also said he expected more Conservative MPs to join UKIP following the defection of Mr Carswell and Mark Reckless, who has triggered a by-election in Rochester and Strood, Kent.

"I think it would be very surprising if more people did not come across", he said.

Mr Farage, who will campaign in Rochester and Strood on Saturday, said he had also spoken to Labour MPs "frustrated that they are not able to change things in British politics".

Media playback is unsupported on your device Media caption Ed Miliband said the Tories lost in "their own backyard" in the Clacton by-election

Mr Cameron said the general election would be "the most important in a generation".

He added: "What last night demonstrates is that if you see a big UKIP vote you end up with Ed Miliband as prime minister, Ed Balls as chancellor, Labour in power."

Speaking in Heywood, where he congratulated winning candidate Liz McInnes, Mr Miliband said UKIP voters did not think political parties listened to them or that the country represented them.

He said Labour had changed and realised it was "not prejudiced" to worry about immigration, but said he did not think UKIP could "represent the interests of working people".

The next election would be a fight against "disillusionment and despair", he predicted.

On a walkabout with Mr Farage in Clacton on Friday morning, Mr Carswell said he did not want to be UKIP leader, and said his old party had "smeared" Mr Reckless since his defection.

In his acceptance speech earlier he told UKIP supporters there was "nothing that we cannot achieve" but urged his party to reach out to as many voters as possible - including first and second generation immigrants - and to "temper" its "passion with compassion".

Image copyright AP Image caption Mr Carswell overturned a Conservative majority in Clacton

Image copyright PA Image caption Liz McInnes retained Heywood and Middleton for Labour but with a reduced majority

Image copyright AFP/Getty Image caption Nigel Farage and Douglas Carswell were mobbed by the press when they walked around Clacton

Media playback is unsupported on your device Media caption Liz McInnes' acceptance speech

Media playback is unsupported on your device Media caption Conservative Party Chairman Grant Shapps: "UKIP's victory is a wake-up call"

In the wake of their narrow victory in Heywood, senior figures defended Ed Miliband's leadership but several MPs have expressed concerns about its electoral strategy.

"If last night's vote heralds the start of UKIP's serious assault into Labour's neglected core vote, all bets are off for safer, let alone marginal seats at the next election." former pensions minister Frank Field MP said.

Mr Field said "very large numbers" of Labour voters were unhappy with the way the party was performing, saying this stemmed from their concerns about levels of immigration.

He added that "until we get that central to our message we're in trouble".

But shadow health secretary Andy Burnham said Labour was "more united" than at any time he could remember since his election in 2001 and Ed Miliband had held the party together after it lost power in 2010.

Analysis by Nick Robinson, BBC political editor

British politics is now a national contest between at least four parties - Conservatives, Labour, Liberal Democrats and UKIP - and arguably five or more if you add the Greens (who are polling as well as the Lib Dems), the SNP (who are threatening Labour's many former Labour strongholds) not to mention Plaid Cymru and Respect.

Read more from Nick

Mr Carswell is the first MP to be elected under UKIP's banner although it did have one MP for two years after 2008 after another Tory MP, Bob Spink, defected to them.

It had also looked at one point that UKIP could have been celebrating a double success with the result in the Greater Manchester constituency of Heywood and Middleton - held comfortably by Labour since its creation in 1983 - deemed close enough to warrant a "bundle check" of votes.

But in the end, Labour's Liz McInnes got 11,633 votes - 41% - with UKIP's John Bickley gaining 11,016 - 39%.

Media playback is unsupported on your device Media caption Prof John Curtice says Douglas Carswell's Clacton win is the largest increase in vote by any party in any UK by-election

Media playback is unsupported on your device Media caption A look back at previous election "first wins"

The Heywood and Middleton contest was prompted by the death of long-serving Labour MP Jim Dobbin last month. His majority at the last general election was 5,971.

The Lib Dems lost their deposit in Clacton, where they were pushed into fifth place behind the Greens with just 453 votes and saw their vote collapse in Heywood and Middleton.

But Energy Secretary Ed Davey said his party was "never going to be in the race" in Clacton and it was "confident" about the future based on its record in government.

Clacton by-election: result in full

Douglas Carswell (UKIP) 21,113 (59.75%)

Giles Watling (Con) 8,709 (24.64%)

Tim Young (Lab) 3,957 (11.20%)

Chris Southall (Green) 688 (1.95%)

Andy Graham (LD) 483 (1.37%)

Bruce Sizer (Ind) 205 (0.58%)

Howling Laud Hope (Loony) 127 (0.36%)

Charlotte Rose (Ind) 56 (0.16%)

Turnout was 51%

Heywood and Middleton by-election: result in full

Liz McInnes (Lab) 11,633 (40.86%)

John Bickley (UKIP) 11,016 (38.69%)

Iain Gartside (Con) 3,496 (12.28%)

Anthony Smith (LD) 1,457 (5.12%)

Abi Jackson (Green) 870 (3.06%)

Turnout was 36%