LONDON — As an island nation that once built an empire by sea, Britain has a proud history and longstanding expertise in shipbuilding.
But, buffeted by cuts in military spending and a decline in demand, the country’s biggest military contractor, BAE Systems, said on Wednesday that it would end more than five centuries of shipbuilding in the southern English city of Portsmouth and cut nearly 1,800 jobs across Britain.

The announcement prompted opponents of Prime Minister David Cameron to accuse him of playing politics with an industry intertwined with the country’s history.

The company is finishing a large order worth several billion pounds to build two aircraft carriers, which had created the largest shipbuilding boom for the company since World War II, by some measures. With that order coming to an end, layoffs had been expected. But the scale of the cuts, worked out in a restructuring plan with the government, came as a surprise.

About 940 shipbuilding jobs will be lost in Portsmouth by the end of next year. That will reduce a port with a history that dates to the building of 16th-century warships like Henry VIII’s Mary Rose to a backwater in which only ship maintenance and servicing will be done. An additional 835 positions will be eliminated in Filton, near Bristol in the southwest of England, and Glasgow and Rosyth in Scotland.

Mr. Cameron tried to cast the cuts in a semi-positive light. “In Portsmouth, yes, there will be job reductions,” he said, “but there are many more people involved in ship servicing than in shipbuilding.”

The government said it would invest £100 million, or $161 million, in an expanded dock in Portsmouth, which will become home to the two new aircraft carriers, H.M.S. Queen Elizabeth and H.M.S. Prince of Wales.

The biggest political backlash could come from the fact that BAE is not only shutting down shipbuilding operations in Portsmouth, but also intends to move some of its shipmaking capacity to Scotland. The company said on Wednesday that Glasgow was the best location to build a new fleet of Type 26 frigates. That contract is the company’s next big order.

Coming a year ahead of a referendum on Scottish independence, the announcement prompted lawmakers in the opposition and labor unions in England to accuse the Conservative government of trading English jobs for Scottish ones in an attempt to persuade Scotland not to secede.

In an animated exchange in the House of Commons on Wednesday, the Labour Party’s new spokesman for military issues, Vernon Coaker, challenged Defense Minister Philip Hammond, questioning whether he was acting in Britain’s national interest.

“What safeguards are in place if Scotland votes to leave the U.K.?” he asked. “None of us wants to see that, but we need to know what plans he has in place for all eventualities.”

Mr. Hammond said, “We have a sustainable naval shipbuilding industry in the U.K. — as of this announcement.”

But even some Conservatives were uneasy. Asked whether she believed that English jobs were being sacrificed for Scottish jobs, Caroline Dinenage, a Conservative lawmaker for Gosport in Hampshire, did not hesitate. “Yes, definitely,” she said on BBC Radio.

The most passionate rebukes came from Portsmouth, where shipbuilding is what wine production is to much of France and auto manufacturing is to Detroit: a cultural identity as much as an industry.

“Portsmouth is the last place in England that has the ability to build advanced warships for the Royal Navy,” said Gerald Vernon-Jackson, the leader of Portsmouth City Council. He said that if Scotland left Britain, the Royal Navy might “have to buy ships from France or Germany.”

David Hulse, chairman of the Confederation of Shipbuilding and Engineering Unions’ national shipbuilding committee, called it “a devastating day for the U.K. shipbuilding industry.”

An additional 3,200 BAE workers employed in maintaining and servicing ships at the naval base in Portsmouth will not be affected by the cuts.