An upstate man busted for shooting a car and then threatening to harm himself is the first person to have his guns confiscated under New York’s new “red flag” law.

Robert King, 51, was accused of illegally possessing and firing a pistol that struck a parked car in New Lebanon, Albany’s News 10 reported.

Cops said that after his arraignment, King said something about hurting himself, so authorities filed an extreme risk protection order.

His weapons — a pistol and seven long guns — were seized on Sept. 4 pending a hearing scheduled for Friday, but King waived the formal hearing “based upon clear and convincing evidence against him,” Judge Patrick McGrath said.

Both sides agreed that the guns would be taken away for a year, although the state can introduce new evidence to extend that period.

King can also request another hearing during the year to try to get the guns back sooner.

King made obscene gestures to reporters outside court, but his lawyer later said he was a good family man, a business owner and a volunteer firefighter.

New York’s red flag regulations, which went into effect last month, prevent people who show signs of being at risk to themselves or others from purchasing or owning a firearm.

Cuomo signed the legislation in February, making New York the 17th state to have such a law.

Senate Deputy Leader Michael Gianaris of Queens, one of the bill’s sponsors, said the bust shows the law is already working.

“Common-sense gun safety reforms save lives,” he told The Post. “Our new red flag law will keep guns away from dangerous people and I am proud to see its enactment is already making people safer.”

National cries to strengthen gun laws resurfaced after the massacres in El Paso, Texas, and Dayton, Ohio, in early August.

President Trump said after the shootings that he was considering a red flag bill, but has thus far not advanced that notion.

The National Rifle Association objects to such bills, arguing that law-abiding citizens could have their weapons seized in violation of the Second Amendment.

Additional reporting by Carl ­Campanile