Scandal-scarred former New York City Comptroller John Liu is attempting a political comeback — emboldened by the stunning upset pulled off last week by Democratic congressional candidate Alexandria Ocasio-Cortez, sources said.

Liu and his hard-left supporters from TrueBlueNY are racing to gain 3,000 signatures so he can run against incumbent Sen. Tony Avella of Queens in the Democratic primary Sept. 13.

The deadline to submit the petitions is Thursday at midnight, according to the city’s Board of Elections.

Avella is the last member of the Independent Democratic Conference to be challenged by a Democrat, even after the mainstream party called a truce with the rogue group that aligned itself with the GOP in a power-sharing agreement.

“We have exciting news!” TrueBlueNY announced in an email to supporters Thursday night. “We’re launching a secret surprise sneak attack on our final IDC member, Tony Avella — BUT WE ONLY HAVE THIS WEEKEND TO DO IT.”

Liu’s bid for mayor in 2013 crashed in a fundraising scandal linked to a previous campaign.

Prosecutors convicted his campaign treasurer, Jia Hou, and a fundraiser, Xing Wu Pan, on charges they attempted to defraud the city during Liu’s 2009 campaign by using straw donors to obtain greater matching campaign funds.

Over the course of the lengthy investigation, Liu was never charged.

After the failed mayoral bid, Liu took on Avella for the northeast Queens Senate seat in 2014 and lost by fewer than 1,000 votes in the September primary.

A source said Liu wasn’t interested in running again, but changed his mind after seeing Ocasio-Cortez defeat Rep. Joe Crowley in last week’s Democratic primary in the 14th Congressional District covering parts of Queens and the Bronx. Crowley is also chairman of the Queens Democratic Party.