LONDON — Prime Minister David Cameron’s Conservative Party fared much better than expected in parliamentary elections Thursday, an exit poll projected, suggesting it is within touching distance of forming a new government.

The opposition Labour Party of Ed Miliband took a beating, according to the poll, much of it because of the rise of the separatist Scottish National Party. The poll said the SNP would take all but one of the 59 seats in Scotland, most of them from Labour.

Cameron’s coalition partner, the Liberal Democrat Party, was expected to lose most of its seats. The exit poll, based on interviews with 22,000 voters, differed strongly from opinion polls conducted during the month-long election campaign, which had put the Conservatives and Labour neck-and-neck with about a third of the vote each.

London Mayor Boris Johnson, who is running for a seat in Parliament as a Conservative, said that if the poll was accurate “then obviously, it’s a very, very clear victory for the Conservatives and a very bad night for Labour.”

Political leaders warned against jumping to conclusions before the actual results are in, and some expressed skepticism about the poll.

“I have to say it just doesn’t feel right,” said longtime Labour adviser Alistair Campbell.

The survey was conducted by pollsters GfK and Ipsos MORI for Britain’s broadcasters and released as polling stations closed at 10 p.m.

Results began coming in within an hour of polls closing. The seat of Houghton and Sunderland South in northeast England was the first to complete the traditional election-night ritual: Votes in each of the 650 constituencies are counted by hand and the candidates – each wearing a bright rosette in the color of their party – line up onstage as a returning officer reads out the results. It went to Labour, as expected.

The exit poll projected that the Conservatives would get 316 seats – up from 302 and far more than had been predicted – and Labour 239, down from 256. The Liberal Democrats would shrink from 56 seats to 10, while the Scottish nationalists would grow from six to 58.

There could be a re-run of the Conservative-Liberal Democrat coalition that has governed since 2010.