Ocasio-Cortez. Photo: Scott Heins/Getty Images

Minutes after the polls closed, and the first returns started trickling in, Joe Crowley knew his two-decade career in Congress was over. Alexandria Ocasio-Cortez, a 28-year-old upstart who a year ago was working as a bartender at the gourmet Manhattan taqueria Flats Fix, and who had been inspired to run by Bernie Sanders, had swamped Crowley everywhere, from the barrios of the Bronx to the white liberal enclaves of Astoria and Jackson Heights.

Joe Crowley was the chairman of the House Democratic Caucus, the likely next Speaker of the House and for a decade and a half had presided over the Queens County Democratic machine.

But this isn’t the machine age, it’s the Instagram era, and it’s not clear that old-school party apparatuses are worth much anymore. Crowley was torched for not attending a debate with Ocasio-Cortez in the Bronx, and sending a surrogate, former councilmember Annabel Palma in his stead. “His seat is not his entitlement. He’d better hope that voters don’t react to his snubs by sending someone else to do the job,” the Times wrote in a scathing editorial.

When Ocasio-Cortez hit him on it at a subsequent debate in Queens, Crowley sounded genuinely perplexed.

“I didn’t send anybody,” he responded. “I asked. I can’t send anybody to anything.”

Crowley Photo: Al Drago/The New York Times/Redux

At Crowley’s election-night party at the Queensboro, a hip new restaurant in Jackson Heights where Ocasio-Cortez pins were far more likely to be found most nights on the clientele, there were no TVs set up to watch the returns, and so Crowley supporters, which included most of the city’s political class, stayed glued to their smartphones, constantly refreshing the Board of Elections website.

“I’m outta here,” said one Democratic Party operative as the pathway to a Crowley victory began to look impossibly narrow. “I’m going to the Bronx. I voted for her.”

When Crowley entered the restaurant, he conceded immediately, pledging to support Ocasio-Cortez. “We have a great chance to take back the House this fall. And although I may have been sacrificed a little early, I am committed to that cause,” Crowley said while longtime aides nursed large glasses of wine and started to cry.

Crowley, with his band behind him, then launched into a rip-roaring version of “Born to Run,” dedicated to Ocasio-Cortez.

After he was finished, he pivoted toward the door to go home, then turned and plunged into the crowd of well-wishers. Someone brought him a lager.

“I may not have gotten proper credit for all the things I have done,” Crowley told New York while the band played “Ramblin’ Man” behind him. “The people in this district know me. It was a Democratic primary at a time of low turnout. It is what it is.”

He defended not going to the debate in the Bronx, saying that the paper that sponsored the debate “had already endorsed my opponent, and they wouldn’t work with my schedule.”

“I was never a good debater anyway,” he added. “I think anybody who has ever seen me debate knows that.”

Crowley’s campaign team had no sense that he was vulnerable. Andrew Cuomo had won the district by over 40 points in 2014 against a liberal insurgent, and Hillary Clinton beat Bernie Sanders by over 20 there in 2016. Crowley’s team had him up by over 30 points a few weeks out, and his campaign team pegged a 15-point win as a disappointing showing. Crowley is from a political dynasty, one that has been in Queens politics for more than 40 years. His district is staggeringly diverse, with a 50 percent Hispanic population and 70 percent minorities overall. It is so diverse that the various ethnic groups had not coalesced around an outsider candidate before.

And they didn’t entirely this time either. Crowley won the African-American precincts and performed well in the Hispanic and Asian ones, but he got overwhelmed by white gentrifying liberals in Astoria, Jackson Heights, and Woodside in numbers unlike any that campaign pros had seen before.

“People are just really, really angry,” said Corey Johnson, the Speaker of the City Council who owes his position as the head of that body in part to Crowley’s corralling of Queens councilmembers in Johnson’s favor.

And it was not an anger that the jovial Crowley, a backslapping pol from another era, was able to match.

“Joe Crowley is an old-school guy. He is one of the nicest, most loyal people I have ever known. You will not find a bigger mensch in politics,” Johnson said. “I am devastated.”

Crowley’s team never went negative against Ocasio-Cortez, in part because of the big lead they thought they had, and in part because of the optics of bringing the fight to a young woman of Puerto Rican descent in a district that is just 25 percent white, and in part because it wasn’t Crowley’s style.

Ocasio-Cortez had no such qualms, at one point suggesting to an interviewer that there was a Crowley-led conspiracy to rig the voting machines against her. She railed against Crowley’s ties to the Queens machine, in particular highlighting how high-level officials in the county Democratic Party serve as lawyers before Surrogate’s Court.

“He was the chairman of the Wall Street New Dems. That is totally inappropriate,” Ocasio-Cortez said in an interview in front of her campaign office late last week. “He is manufacturing a foreclosure crisis by working with his donors. It is to me completely disqualifying for this community, as working class as it is.”

She hit him for helping to create ICE — she favors abolishing the agency — and for working to weaken Dodd-Frank. She railed against him for residing in the D.C. suburbs, where he is raising his three children with his wife. “A Democrat who takes corporate money, profits off foreclosure, doesn’t live here, doesn’t send his kids to our schools, doesn’t drink our water or breathe our air cannot possibly represent us,” she said in a soaring and viral web video that laid out her candidacy.

In an interview, Ocasio-Cortez conceded that Crowley was not the worst Democrat in Congress, but argued that he was far too middle of the road for a district that is so overwhelmingly Democratic.

“He is a rep that should be elected in Virginia, not the Bronx,” she said.

The Queens Democratic Party had 300 foot soldiers knocking on doors on Crowley’s behalf on Election Day, and he had every major union in the city doing the same. Ocasio-Cortez went to doors that don’t often see politicians knock on them; many didn’t know there was even a primary happening, which allowed her to make her case. And although she was largely ignored by the mainstream press, she received warm coverage from websites that rely heavily on a female readership, and liberal news sources gave such fawning coverage that campaign aides joked that stories from the Intercept should count as an in-kind donation to her campaign.

Liberals are as angry now as their tea party brethren across the aisle were a few years ago, and Crowley is as an Establishment figure as they come. “People know me as a national figure, not a local one,” Crowley said. “But in the end I think I always maintained my connectivity to the district.”

And he disputed the notion that a district so diverse should not have a white congressman.

“No, look. I think I have as much to offer as anyone in terms of my expertise and my proven leadership. But at the end of the day it’s not about me. It’s about the people. I give my opponent, Alexandria Ocasio-Cortez, a lot of credit,” he added. “She ran a good race.”

As aides and supporters spilled out onto Northern Boulevard and the hour grew late, Crowley continued to nurse a beer and work the room. An era was over. The band kept playing. After 11, they launched into “Margaritaville.” At the line “Some people claim that there is a woman to blame, but I know it’s nobody’s fault,” everybody sang along.