(Reuters) - More than a year of work to bring Amazon.com Inc’s headquarters and tens of thousands of jobs to New York City ended on Thursday with a couple of phone calls.

Jay Carney, the company’s top policy executive, told New York Governor Andrew Cuomo that the world’s biggest online retailer would not go ahead with plans to invest $2.5 billion to build a second head office in the New York City borough of Queens.

Carney, a former press secretary for President Barack Obama, told New York City Mayor Bill de Blasio the same shortly after.

Abruptly scuttling its Big Apple plans blindsided Amazon’s allies and opponents alike. The company said the decision came together only in the last 48 hours, made by its senior leadership team and Jeff Bezos, Amazon’s founder, chief executive and the richest person in the world.

Yet by some measures the decision was months in the making, as community opposition signaled to the company that it was not entirely welcome.

The abrupt reversal has made the company a target of ire from progressives like U.S. Representative Alexandria Ocasio-Cortez who are swiftly gaining ground and influence in the U.S. Democratic party. It may also play into an intensifying battle between Republicans and Democrats as President Donald Trump and his allies accuse left-leaning rivals of embracing socialism.

The decision has also generated fresh debate about the rich tax-breaks and public funding that municipalities routinely throw at companies to lure their business and the jobs they bring with them.

Seattle-based Amazon captivated elected officials across North America in September 2017 when it announced it would create more than 50,000 jobs in a second headquarters dubbed HQ2. Cities and states vied desperately for the economic stimulus, with New Jersey offering $7 billion in potential credits and the mayor of an Atlanta suburb promising to make Bezos mayor for life of a new city called “Amazon.”

A backlash began in earnest when Amazon announced two winners to split the offices last November: Arlington, Virginia, and New York’s Long Island City neighborhood, with New York offering incentives worth $1.53 billion to Amazon. The company could apply for $900 million more, too.

A delivery person pushes a cart full of Amazon boxes in New York City, U.S., February 14, 2019. REUTERS/Brendan McDermid

New York State Senator Michael Gianaris and City Council Member Jimmy Van Bramer said that day that it was “unfathomable that we would sign a $3 billion check” to one of the world’s most valuable companies considering the city’s crumbling subways and overcrowded schools.

City Council meetings in December and January showed Amazon executives who showed up the stern opposition they could expect from some elected officials and labor organizers.

Protesters interrupted the meetings. A television report showed people unfurling signs saying, “Amazon delivers lies,” and “Amazon fuels ICE deportations” - a reference to the company’s cooperation with the U.S. Department in charge of Immigration and Customs Enforcement (ICE).

Amazon felt that a small number of local and state officials had no desire to collaborate on a path forward, the company later said, despite what it said was strong popular support for its project.

RELATIVELY PAINLESS EXIT

Tension ratcheted up earlier this month, when Gianaris was nominated to a state panel set to vote in 2020 on whether to approve the financial terms for Amazon.

Days later, Amazon executives weighed the pros and cons of whether to follow through with its New York headquarters, two people briefed on talks inside the company said. Concerned that Amazon could be in limbo for more than a year ahead of the state panel’s vote, the growing consensus within the company was that it did not make sense to move ahead in the face of persistent opposition with a headquarters in New York City, where it already has 5,000 employees.

Amazon had no binding legal contracts to acquire or lease the land for the project. It could exit with relatively little pain, the people said.

Company officials also concluded Amazon could shift the jobs that would have been created in New York to other corporate centers it has across the United States, from the San Francisco Bay Area to Boston. Reopening talks with former HQ2 contestants did not make sense, the people said.

Gianaris blamed Amazon for the reversal.

“Amazon never showed willingness to look seriously at the concerns that were raised,” he said.

Still, up to the moment of the announcement, there were signs that the parties could work together.

One union leader said he and other labor organizers met on Wednesday with Cuomo and four Amazon officials, including Brian Huseman, its vice president of public policy.

“We had such a productive meeting yesterday. Everyone left happy,” said Stuart Appelbaum, head of the Retail, Wholesale and Department Store Union.

The group is trying to organize workers at an Amazon facility in Staten Island, another New York City borough, despite the company’s past opposition to unionization.

“It was a complete surprise that they would say they look forward to working with us, and we talked about next steps, and then they call it all off the next morning,” said Appelbaum.