Amazon put two years and untold amounts of staff time and money into negotiating with New York to save about $3 billion on a new campus in one of America's most dynamic cities. It bypassed legislative bodies to avoid getting bogged down in local politics.

And it kept the whole process secret, allowing the company, the mayor, and the governor to present the agreement as a fait accompli.

Where did Amazon go wrong? After staging a highly public auction that drew bids from hundreds of cities, the company attempted to craft uncrackable deals with its chosen cities that would avoid community input until most of the details were worked out. In New York, that may have ultimately led to the agreement's demise.

"There should've been an opportunity to sit down with them. Instead there was a rush to judgment on this," said Sid Davidoff, an attorney who has represented developers before New York regulators. "Maybe they should've said, 'We have a lot of things to work out, but we want our home to be New York and we want to work with you.'"

Here's the thing about local politicians: They don't like feeling bigfooted or evaded. Council members who may have been persuadable turned hostile when Amazon showed little interest in further conversation about how to mitigate the traffic congestion and rising housing costs that could have ensued when thousands of highly paid tech workers flooded Queens.

"If they were interested in being a partner, then they would engage in dialogue and conversation about these issues," said Brooklyn Council Member Brad Lander. "Amazon doesn't want the rules we've democratically set. They want a monopolistic version."

That wouldn't have been a problem if local politicians had no leverage as it at first appeared they had to influence benefits negotiated by Mayor Bill DeBlasio and Governor Andrew Cuomo.

But the ground was shifting underneath them. Democratic insurgents toppled moderates in the state senate in last November's elections, giving them more power to oppose Cuomo. They flexed that muscle a few weeks ago, when the new senate majority leader, Andrea Stewart-Cousins, appointed a vocal opponent of Amazon's plans to a state board that would vote on the deal.

That opponent, State Senator Michael Gianaris, originally advocated for the company to come to Queens, then changed his mind. In a press conference following Amazon's announcement on Thursday, Gianaris said he didn't anticipate it would come with a $3 billion incentive package. He said he'd been locked out of the bargaining process from day one.

Instead of dealing with those questions in a responsible way, Amazon took its ball and left town." Michael Gianaris

"An affected community raised its hand and said, 'I have some questions about this deal that we knew nothing about,'" Gianaris said. "Instead of dealing with those questions in a responsible way, Amazon took its ball and left town."

In the year since the bids were submitted, Gianaris said he'd soured on the company for its stance against unionization of workers at Whole Foods and in Amazon warehouses. He also opposed Amazon's attempt to provide its facial recognition technology to immigration enforcement officials.

Retail and trucking unions organized protests and media outreach to fight the deal, and political animosity hardened after Amazon's representatives said at a city council hearing that they would continue to oppose labor organizing efforts.

"It was Amazon that said they're unabashedly anti-union, and proud of that fact," Gianaris said.

Even Amazon's defenders say the company could have better communicated what it was getting and what it would be giving back. They point out the company was entitled to most of the incentives through "as-of-right" sweeteners like the Excelsior jobs program and the Relocation and Employment Assistance Program , which would have been available to any company, rather than one-time money granted at the governor's discretion.

Protesters hold up signs as executives from Amazon testify at a City Council hearing.

"Amazon would've benefited from providing more transparency throughout the process," said Julie Samuels, the head of Tech:NYC, a coalition of tech companies that counts Amazon among its members. "Amazon would have benefited from having more details at the outset about how it was going to invest in the community. With hindsight, some specifics might have been useful."

Of course, some groups would have opposed Amazon coming to Long Island City no matter what the company promised. The community development non-profit Make the Road New York had been canvassing local housing projects for months, talking to residents about high housing costs and gentrification in Seattle, where Amazon is based.

"Having them not force their empire-building on Queens neighborhoods is exactly what we want," said Make the Road co-executive director Deborah Axt on Thursday. "Amazon is a predatory business model that has been built on killing small businesses, partnering with ICE, and tax evasion."

Few people on the ground made the case for Amazon. The state argued the company would generate $27 billion in new government revenue. Amazon promised school funding and job training. But that outreach was mostly managed by executives out of Seattle and Washington DC, which didn't engender trust.

"I think we need New Yorkers to run the rollout, to manage the process, to deal with electeds," said Carlo Scissura, president of the New York Building Congress, a coalition of real estate interests. He remembers dealing with opposition to the NBA's Nets moving to Brooklyn when he led the Brooklyn Chamber of Commerce, which ultimately got done after years of delay. "You know what, we stuck it out."

Amazon sent several rounds of mailers to Long Island City residents in early January touting the project, and there were a few petitions of local residents and businesses supporting Amazon's plans. After the Washington Post reported that Amazon was considering backing out of the deal last week, the Long Island City Partnership hastily convened a press conference with presidents of local tenants' associations to talk about why they wanted Amazon as a neighbor.

It wasn't enough to sway local politicians, and it didn't convince Amazon there would be enough community support to get it through what would have been a long development process.

Mitchell Taylor , CEO of Queens economic development non-profit Urban Upbound and co-chair of the Amazon HQ2 Community Advisory Committee, had a meeting with Amazon liaisons on Thursday morning before the announcement and didn't hear that anything was amiss.

He had been looking forward to the new campus, anticipating positive spillover effects for jobs and education in the community. When he heard the news, he said, "My visceral reaction was cataclysmic."

He wished Amazon had managed to control the narrative sooner.

"I definitely think they could've had stronger messaging," Taylor said. "I think we all have to be better at forcing people to the table, rather than allowing people to roam with the opposition."