The Justice Department says it won’t “stand idly by” while the city introduces supervised sites for heroin users to inject drugs — something the feds consider a “violation of the Controlled Substances Act.”

In a letter to state Assembly Member Nicole Malliotakis (R- Staten Island), a 2017 mayoral candidate who had notified the DOJ of her concerns about the endeavor, intergovernmental liaison Jessica Hart wrote that federal prosecutors oppose the plan.

“Government sponsored injection sites are utterly incompatible with the appropriate government response to the opioid epidemic,” Hart wrote in a letter dated Sept. 12.

“The Department of Justice’s Agents and prosecutors will not stand idly by while misguided, dangerous and destructive federal criminal violations take place,” she added.

“The Department will, as always, enforce the law where prosecution will serve a substantial federal interest.”

The federal opposition could be a significant obstacle to Mayor de Blasio’s plan to open 4 sites across the city where addicts can have a safe place to inject drugs, while getting access to services and potentially life-saving Naloxone.

The mayor announced in May they’d be open within 6 to 12 months as one-year pilot programs at existing needle exchange centers in the Gowanus neighborhood in Brooklyn, west Midtown, Washington Heights and the Longwood section of The Bronx.

City officials said at the time that they would seek authorization from the state Health Department, district attorneys and the local City Council member in each pilot district before proceeding.

On Monday, they said they’re still working to get state authorization, and they defended the program.

“Our 2017 data indicates that New York City’s strategy to fight opioid overdoses is helping to slow down the epidemic,” said City Hall spokeswoman Marcy Miranda. “It’s our moral obligation to connect people to treatment that’s proven to work, not criminalize them for trying to get better. We’re committed to using every tool at our disposal to save lives.”

Federal officials said that while San Francisco, Seattle and Philadelphia are similarly seeking to launch supervised injection facilities, there is currently “no reliable evidence” that the sites reduce overdose deaths.

There were 1,487 drug overdose deaths in the five boroughs in 2017.