Amazon canceled plans to build a campus in New York City with at least 25,000 high-paying jobs on Thursday because of resistance from local elected officials, unions and community activists who said a project initially hailed as an economic triumph was a lousy deal.

“There are a number of folks on the ground who oppose our presence,” Amazon spokesman Jodi Seth said. “We don’t think there’s a path forward in terms of working with them over the long term.”

The company issued a statement shortly before noon saying it did not intend to reopen its search for a second headquarters at this time, but would continue with plans to put at least 25,000 jobs in Arlington in northern Virginia and 5,000 in Nashville, Tenn.

The decision was a stunning reversal for Amazon, which badly miscalculated how it would be received when it said it would put half of the 50,000 jobs promised in its much-publicized HQ2 search in the Long Island City neighborhood of Queens.

While Gov. Andrew Cuomo and Mayor Bill de Blasio, both Democrats, celebrated the announcement, and opinion polls showed large majorities in favor of the deal, a strong backlash quickly developed.

Opponents, including freshman Rep. Alexandria Ocasio-Cortez, D-N.Y., protested that the influx of Amazon employees, to be paid an average salary of at least $150,000 a year, would cause housing costs to skyrocket, drive out low-income residents and worsen congestion on the subway and streets.

They also objected to up to $3 billion in state and local incentives promised to Amazon, which they said should not get such subsidies given that it is the world’s most valuable company and headed by Jeff Bezos, the world’s wealthiest person.

(Amazon founder and CEO Bezos owns The Washington Post.)

Some of Amazon’s competitors, such as Google, have expanded their presence in New York — and taken advantage of its high-tech talent pool — without seeking large state subsidies.

Amazon’s announcement came six days after The Washington Post broke the news that the company was reconsidering the New York project because of local opposition. That report prompted more than a dozen jurisdictions that pursued the deal originally — including Washington, Chicago, Miami and Newark — to reach out to Amazon again in hope of luring the jobs if the New York deal collapsed.

But the company said it was not looking to put all 25,000 of the jobs slated for New York in a single location.

“We do not intend to reopen the HQ2 search at this time,” the company said in a blog post. “We will proceed as planned in northern Virginia and Nashville, and we will continue to hire and grow across our 17 corporate offices and tech hubs in the U.S. and Canada.”

Virginia Del. Rip Sullivan said an Amazon contact told him Thursday morning that the pullout from New York has “no impact on their plans for Arlington, their schedule or scope of plans” in northern Virginia.

New York Mayor Bill de Blasio, whose support for the Amazon project disappointed many of his liberal supporters, faulted the company for backing out.

“You have to be tough to make it in New York City,” de Blasio said in a statement. “We gave Amazon the opportunity to be a good neighbor and do business in the greatest city in the world. Instead of working with the community, Amazon threw away that opportunity. We have the best talent in the world and every day we are growing a stronger and fairer economy for everyone. If Amazon can’t recognize what that’s worth, its competitors will.”

A New York union that helped lead the opposition also attacked Amazon.

“Rather than addressing the legitimate concerns that have been raised by many New Yorkers Amazon says you do it our way or not at all, we will not even consider the concerns of New Yorkers — that’s not what a responsible business would do,” said Chelsea Connor, spokeswoman for the Retail, Wholesale and Department Store Union (RWDSU).

New York’s resistance to the Amazon project has been in sharp contrast with the generally warm welcome that Virginia gave the company. With little opposition, Virginia has already passed a law granting Amazon up to $750 million in state incentives over the next 15 years, on condition that it create 37,850 new jobs over that period.