LONDON — Britain’s anti-European Union party made big gains in local elections Friday, taking votes from the governing Conservatives and the opposition Labour Party and rattling rivals’ nerves a year ahead of Britain’s national election.

It’s a strong performance for the U.K. Independence Party (UKIP), which advocates pulling Britain out of the 28-nation EU and stopping the unfettered right of EU citizens to enter Britain.

With most results declared Friday from voting for about 4,000 seats in 161 local authorities, UKIP won about 150 seats, nearly double its predicted total of 80.

Labour won the largest share of seats, more than 1,700, gaining more than 250 and doing strongly in London as Britain’s cosmopolitan capital defied the UKIP surge. The gains, however, were less than many Labour supporters had hoped for and not enough to make the party confident of winning next year’s election.

Unlimited Digital Access. $1 for 4 weeks.

Prime Minister David Cameron’s Conservatives lost almost 200 seats, while their coalition partners, the Liberal Democrats, lost even more — about one-third of their total. The BBC said that if projected nationwide, the result would give UKIP 17 percent of votes, compared with 31 percent for Labour and 29 percent for the Conservatives.

UKIP leader Nigel Farage said the result meant “we are serious players” in British politics. “The UKIP fox is in the Westminster henhouse,” he said Friday. He said his party was confident it would elect its first lawmakers to Britain’s Parliament next year. Farage, who has cultivated a jovial, straight-talking image, appeared on TV, dressed in a well-tailored suit and celebrating with a pint of beer.

Cameron acknowledged that UKIP appealed to voters angry about austerity and worried about immigration.

“The economy is growing, we are creating jobs, but we have got to work harder and we have got to really deliver on issues that are frustrating people,” Cameron said.

Britons also voted Thursday in European Parliament elections. Polls suggest UKIP could gain the largest share of that vote for Britain’s 73 seats in that legislature. Those results will be announced Sunday with tallies from 27 other EU countries.

By presenting itself as an alternative, UKIP is making headway in its drive to upend the country’s political system. That seemed implausible eight years ago when Cameron, newly elected as Conservative Party leader but not yet in power, described the populist party as “a bunch of fruitcakes, loonies and closet racists.”

Material from The New York Times is included in this report.