LONDON — Prime Minister David Cameron’s Conservatives took a pummeling on Friday after results of a by-election showed surging support for the right-wing United Kingdom Independence Party.
Such deep inroads into the Conservative vote, if sustained at a general election in two years, could oust the Conservatives from power and usher the Labor Party back into No. 10 Downing Street.
Midterm by-elections in Britain have been notoriously quirky for decades, providing opportunities for protest voting that have often been uncertain predictors of general election outcomes.
But in this case, with the results tracking closely with national polls and with mounting concern within the Conservative Party itself about its election prospects, the vote was widely read as a measure of deep problems for the Conservatives.
Senior figures in Cameron’s party acknowledged privately that the results from Thursday’s vote in Eastleigh, a mainly suburban voting district near the coastal city of Southampton, had thrown the deeply divided Conservatives into further disarray.
But Cameron was quick to assert that the results were quixotic and not a death knell for the party’s prospects in 2015.
‘‘It’s a protest,’’ Cameron said after the Eastleigh results showed the Independence Party taking 28 percent of the vote, pushing the Conservatives, with 25 percent, into third place. ‘‘That’s what happens in by-elections.’’
The winners, with 32 percent of the vote, were the Liberal Democrats, a left-of-center party that has been in an increasingly fractious governing coalition with the Conservatives since the general election in 2010.
Observers attributed the Independence Party’s surge — its best result ever in a parliamentary by-election — to its relentless campaigning on two issues that have a powerful resonance among right-of-center voters: high levels of immigration and Britain’s membership in the 27-nation European Union.
European directives on a wide range of social, economic, and judicial issues have been a persistent source of discontent among British voters generally and a cause of longstanding strife among Conservatives.
Cameron, whose leadership has been widely questioned among a powerful bloc of mainly right-wing Conservative legislators, said he would not change the policies that have led to discontent with him and suggestions that the party seek a new leader before the 2015 general election.
Among those policies are Cameron’s decision to support a same-sex marriage bill that is moving through Parliament and to seek to renegotiate the terms of Britain’s membership in the EU rather than quit the European bloc, as the Independence Party and many right-wing Conservatives advocate.
Some of his critics say that in seeking to placate his Liberal Democrat partners and hold the coalition together by adopting policies taken from the Liberal Democrat playbook, notably on same-sex marriage, Cameron has abandoned core Conservative beliefs.
“It’s disappointing for Conservatives,’’ Cameron said, referring to the Eastleigh vote. ‘‘But we will remain true to our principles, true to our course in a way that can bring back’’ the sort of Conservative voters who defected.