The watershed moment that led Amazon to reconsider coming to Queens came on Feb. 4 — when a fierce political foe was appointed to a state board with the power to thwart the project, said sources involved in the discussions.

That was the day state Senate Majority Leader Andrea Stewart-Cousins nominated Sen. Michael Gianaris as her appointee to the obscure Public Authorities Control Board.

Gianaris, who represents Long Island City, where Amazon was planning to build one of its new headquarters, bitterly opposed the $3 billion in subsidies offered by the city and state and was miffed that Gov. Andrew Cuomo and Mayor Bill de Blasio didn’t consult him on the deal, according to sources.

Gianaris’ selection rattled the company.

“Amazon saw it as a sign that the state Senate was against the deal. It put the deal over the cliff,” the insider said.

A second source said, “That really shook them up. It had a chilling effect.”

Three days later, Gianaris went on Fox 5’s “Good Day New York” to demand the deal be scrapped and renegotiated.

And the following day, the Washington Post — owned by Amazon founder Jeff Bezos — reported that the e-tail giant was considering pulling out of the project. Cuomo warned that the threat was real.

The company tried to reach out to Gianaris — but he rejected three invitations to meet, according to a source.

Another high-profile Amazon opponent, Queens Councilman Jimmy Van Bramer, had no such reservations and sat down with company officials.

A “toxic relationship” between Cuomo and Gianaris contributed to Amazon’s woes, said the source.

Gianaris has accused Cuomo of bolstering the now-dissolved Independent Democratic Conference, which for years helped Republicans maintain control of the Senate.

Incredibly, the two men never sat down once to discuss a possible compromise on Amazon.

“It didn’t happen and it should have happened,” the source said.

Still, Amazon’s stunning announcement Thursday caught just about everyone off guard.

Just Wednesday, Cuomo arranged a meeting at his Manhattan office with four top Amazon executives and labor leaders to smooth over problems, since the company is non-union.

Participants included Mario Cilento, head of the state AFL-CIO, Stuart Appelbaum, president of the Retail, Wholesale and Department Store Union, and George Miranda of Teamsters Joint Council 16.

“I’m surprised they pulled out. It was a productive meeting,” Appelbaum told The Post on Thursday.

“We all shook hands and agreed to follow up.”

City officials met with high-ranking Amazon executives earlier in the week and got no hint of the shocking news to come, said a City Hall insider.

De Blasio described himself as “flabbergasted” by the turn of events.

“It doesn’t make any sense given everything that was done here,” he said during a trip to Harvard University.

Other City Hall officials, too, were in disbelief. “We go through this to build a single homeless shelter,” an insider said of the opposition. “The notion that ‘we can’t take the heat so we’re leaving’ is embarrassing.”

Additional reporting by Rich Calder