* PM Cameron's Conservatives losing support to UKIP
* Anti-EU party threatens Cameron's re-election hopes
* Opposition Labor party under UKIP pressure too
* Labor fights off UKIP to narrowly retain seat (Updates with UKIP statement, Shapps, Alexander)
By Andrew Osborn
CLACTON-ON-SEA, England, Oct 10 (Reuters) - Britain's anti-EU UK Independence Party won its first elected seat in parliament on Friday by a landslide 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, which it almost won too, came as a surprise.
In Clacton, it won 60 percent of the vote after the sitting parliamentarian for Prime Minister David Cameron's Conservatives defected to UKIP, which didn't put up a candidate for the area when it was last contested in 2010.
In Heywood and Middleton, in northern England, a traditional stronghold for the opposition Labor party, UKIP 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. Cozy cartel politics is not meaningful democracy. Change is coming."
There is little prospect for now of UKIP winning more than a half a dozen of 650 seats in a national election in May next year. But its success threatens to split the center-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.
Grant Shapps, the chairman of Cameron's Conservatives, said UKIP's success, if repeated next year, would hand victory to Labor leader Ed Miliband.
"This is an alarm clock moment. This is a stark message," he told BBC radio. "If what has happened last night were repeated in 210 days at a general election and you saw Conservative become UKIP seats what you'd have is Ed Miliband in government."
UKIP's success is likely to raise pressure on Cameron to become more Eurosceptic, three years before a referendum on EU 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 center, 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.
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.
UKIP also polled unexpectedly strongly in another special election held on Thursday in northern England after the death of the area's Labor member of parliament.
UKIP said that result showed it was a threat to the established left as well as the right.
"It underlines the scale of the challenge facing Labor," Douglas Alexander, the party's campaign chief, said. Some Labor lawmakers said it resurrected doubts about Miliband's leadership.
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 Labor."
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.
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 Labor, 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.
"British political history was made," UKIP said of its win in Clacton in a triumphant post-election statement, saying both the Conservatives and Labor would now be "busily reassessing the political landscape." (Additional reporting by Kylie Maclellan; Editing by Guy Faulconbridge)