Undercover cops pulled off Sunday’s bust of a massive interstate gun-smuggling ring with the help of a local arms dealer they had collared just days earlier, The Post has learned.

The NYPD was minutes away from holding a press conference to announce the arrest of two members of a Brooklyn-based gun-trafficking ring last Wednesday when one of the pair started cooperating, law enforcement sources said.

The press conference was scrubbed as investigators began plotting to nab their out-of-state gun suppliers, sources said.

With the help of their newfound canary, a black-market buy was set up for Sunday with the Ohio gun-runners, officials said.

A gas station in Springfield Gardens, Queens was picked for the meeting, but undercover cops were staked out over a wide area so the traffickers could be kept under surveillance as they arrived, sources said.

The strategy proved crucial.

Undercover cops spotted one of the Ohio gun-runners – identified as Matthew Brown, 19 – being dropped off with a box of handguns at a construction site in Springfield Gardens, just off the Belt Parkway.

While Brown slipped inside a Porta-Potty at the site with the cache of weapons, his three accomplices drove on to the meet, just two blocks away, where they expected to collect their loot and tell their buyers where they could find the guns.

If the undercover cops hadn’t seen Brown hide out in the portable bathroom with the high-powered arsenal, the sting could have been a fiasco because his buddies had no weapons with them when they were busted, sources said.