U.K. Independence Party supporters carry campaign posters as they walk to the campaign offices of Douglas Carswell, their candidate in the Clacton by-election, on Tuesday. Associated Press

LONDON—Voters in the English seaside constituency of Clacton-on-Sea headed to the polls Thursday in a keenly watched by-election that is expected to usher in the first elected parliamentarian for the U.K. Independence Party and underscore the electoral threat Prime Minister David Cameron faces from divisions on the right.

A win for UKIP, which wants Britain to leave the European Union, would highlight the growing threat that the small party could draw votes away from Mr. Cameron’s center-right Conservative Party in May’s general election and potentially make it harder for him to win a second term.

The front-runner in Clacton, Essex, is Douglas Carswell, who recently announced he was switching to UKIP from the Conservatives and holding a by-election. A recent survey by pollster Survation put his support at 64%, compared with 20% for his Conservative rival and 15% for the Labour Party candidate.

The outspoken euroskeptic lawmaker surprised Westminster watchers in August when he announced he was defecting to UKIP because he thought the Conservative leadership wasn’t serious about political reform or changing Britain’s relationship with Europe.

Mr. Carswell called a by-election to contest the seat under his new political colors.

If he is victorious, the move is likely to provide UKIP with the added credibility of having an elected representative in Westminster and give the party a national platform ahead of 2015.

Mr. Cameron has said that the Conservatives are the only party with a chance of winning the election that is offering a referendum on Britain’s EU membership. He has also warned that a vote for UKIP will end up benefiting the main opposition Labour Party in the event of a tight battle between the two major parties. While UKIP remains a small party, it poses a threat to the Conservatives as it could drain away votes in closely fought constituencies.

“If you vote UKIP, that’s really a vote for Labour,” said Mr. Cameron in an address to his party’s big annual conference earlier this month. “Here’s a thought, on 7th May you could go to bed with [UKIP leader] Nigel Farage and wake up with [Labour leader] Ed Miliband, ” he said.

Mr. Carswell’s chief challengers in Clacton are Conservative candidate Giles Watling and Tim Young from the center-left Labour Party. Polls close at 10 p.m. local time Thursday and the result is expected around 2.30 a.m. on Friday, the local council said. Media interest is intense, with journalists representing outlets from as far afield as Japan and Russia due to cram into the venue along with the domestic media to cover the result, it said.

UKIP, which was formed in the early 1990s, has attracted growing support in recent years through its tough stance on immigration, its criticism of the established political parties, and the charisma of leader Nigel Farage. The small party scored its biggest triumph to date when it won the U.K. European Parliament elections in May, part of a wave of successes by anti-EU parties across Europe, but it has yet to win a U.K. parliamentary seat.

Although Clacton is likely to dominate the headlines in Britain on Friday, the parties will also be contesting another by-election on Thursday in the northern English constituency of Heywood and Middleton. That contest was triggered by death of Labour stalwart Jim Dobbins, who had been the parliamentarian in the constituency in the Manchester metropolitan area since 1997.

Analysts said Labour is likely to retain that seat, but UKIP’s performance there is also likely to draw interest after Mr. Farage declared last month that his party was “parking our tanks on the Labour Party’s lawn” and looking to woo blue-collar workers.

Mr. Carswell won the Clacton seat from Labour in 2005 by just 920 votes. But by the 2010 general election the then-Conservative politician had extended his majority to more than 12,000. Clacton, with its high proportion of retirees and areas of deprivation, is seen by analysts as fertile ground for UKIP’s stance against immigration and the political establishment.

Mr. Carswell’s defection was followed a couple of weeks later by another Conservative lawmaker, Mark Reckless, who also jumped ship to UKIP and triggered a by-election in his constituency. Both were part of a vocal and rebellious euroskeptic wing of the Conservative party, many of whom share UKIP’s desire to see Britain leave the EU. That by-election is due to take place in early November in Kent, southeast England.

Pressure from that group helped push Mr. Cameron to make a pledge last year that if he won a second term he would renegotiate Britain’s relationship with the EU and then hold a national referendum on its membership of the bloc by the end of 2017. That pledge has failed to placate some on the right of his party.

Write to Nicholas Winning at nick.winning@wsj.com