Joe Crowley — the former congressman that Rep. Alexandria Ocasio Cortez defeated in a stunning upset — resigned as the longtime chairman of the Queens Democratic Party, sources said Tuesday.

The resignation takes effect immediately.

The decision came the same day it was revealed that Crowley had joined one of Washington, D.C.’s largest lobbying firms, Squire Patton Boggs.

Crowley has been the party boss since 2006.

But his clout was diminished after his devastating loss in last June’s Democratic primary to Ocasio-Cortez in the 14th congressional district that takes in parts of Queens and the Bronx.

Crowley lives in Virginia with his family while maintaining a residence in Woodside.

But he was still re-elected as party chairman by Democratic district leaders in September.

Sources said the election was intended to allow Crowley to serve one more term and then step down “with dignity.”

But the lobbying gig triggered a speedier departure.

Reps. Greg Meeks and Grace Meng are considered potential replacements.