(Reuters) - Britain's anti-EU UK Independence Party won its first elected seat in parliament on Friday by a huge margin and came a close second in another vote, proving it poses a threat to the country's two main parties in a national election next year.

UKIP, which wants a British EU withdrawal and strict curbs on immigration, was expected to do well in both votes. But the unexpectedly wide margin of its victory in the seaside town of Clacton and its strong performance in an election in northern England came as a surprise.

In Clacton, it won 60 percent of the vote, up from zero in 2010 when it didn't contest the area. In Heywood and Middleton, in northern England, a traditional stronghold for the opposition Labour party, it got almost 39 percent of the vote, up from less than 3 percent in 2010.

“There is nothing that we cannot achieve,” Douglas Carswell, Clacton's new UKIP member of parliament, told supporters.

Quoting Abraham Lincoln’s Gettysburg Address and the words of John Wycliffe, a 14th Century dissident translator of the bible into English, Carswell said he backed “government of the people, by the people, for the people.”

“The governing can no longer presume to know what is right for the governed," he said immediately after he was declared the winner. "Crony corporatism is not the free market. Cosy cartel politics is not meaningful democracy. Change is coming."

There is little prospect of UKIP winning more than a dozen of 650 seats in a national election in May next year. But its growing success threatens to split the centre-right vote and chip away at the traditional left-wing vote too making it harder for any one party to win an outright majority.

That increases the likelihood of a hung parliament, another coalition government, and potential political instability in the world's sixth largest economy.

UKIP's success is also likely to increase pressure on Prime Minister David Cameron to become more Eurosceptic, three years before a referendum on European Union membership which he has promised to hold if re-elected.

Douglas Carswell, a Eurosceptic, defected from Cameron's Conservatives in August, triggering Thursday's Clacton vote. He switched allegiance because he said he doubted the prime minister's determination to reform the EU.

Cameron has promised to try to renegotiate Britain's EU relationship before offering voters an in/out membership referendum in 2017. But some of his own lawmakers are skeptical about his resolve to push for real change, viewing his promise as a tactical move to try to hold his divided party together.

With a population of 53,000, Clacton, once a thriving seaside resort, began to decline as Britons turned to cheap foreign package holidays in the 1980s. It now earns its keep from retirees and day trippers from London.

Retirement homes line the seafront, gaudy arcades filled with slot machines and bookmakers dominate the town centre, and caravan parks luring low-income families with cheap deals sit on the outskirts along with Jaywick, an area officially rated as one of the most deprived in the country.

UKIP-FRIENDLY CONSTITUENCY

Reading newspapers in his souvenir shop at the end of Clacton's 19th-century pier, David Ashton, 66, said on Thursday he had voted UKIP because he had lost faith in Cameron.

"Ever since I was old enough to vote I have always voted Conservative," he told Reuters. "But this time I voted UKIP. This place needs a shake-up. The Conservatives have promised stuff before and not delivered. I don't trust them any more."

He cited their failure to curb immigration and what he said was their desire to remain in the EU, something he opposed.

In terms of its demographics, Clacton is the most UKIP-friendly constituency in the country, according to pre-election analysis by academics Matthew Goodwin and Robert Ford.

"It's very white, very old, very working class, lots of economic deprivation and ... there is a heightened anxiety over migration and Europe," Goodwin said.

UKIP also polled unexpectedly strongly in another special election held on Thursday in northern England after the death of the area's Labour member of parliament.

UKIP said that result showed it was a threat to the established left as well as the right.

Tapping into a weariness with mainstream politics, UKIP won European elections in Britain in May and poached two of Cameron's lawmakers in the last six weeks.

Cameron's strategy to stem UKIP's rise has been to warn voters that "a vote for UKIP is a vote for Labour".

Cameron, who once derided UKIP as a bunch of "fruitcakes, loonies and closet racists", has also said his is the only party able to deliver a referendum on EU membership.

His party shrugged off its defeat in Clacton, putting it down to Carswell's defection. The ballot was not representative of how people would vote in a national election when much more was at stake, Conservative lawmakers said.

However, UKIP believes its success will begin to unravel a political establishment under which until recently Britain's two main parties, the right-leaning Conservatives and left-leaning Labour, have taken turns to govern.

Though a setback to Cameron, Conservative strategists said a defeat in Clacton would be manageable. They are more concerned about the possibility of defeat in another special election.

Triggered by another defection to UKIP, the election, expected in November will be in Rochester, a part of southern England where voters are seen as less UKIP-friendly. The UKIP candidate there, Mark Reckless, a former Conservative, is regarded as far more vulnerable than Carswell.