A Colorado man was busted with 40 pounds of street -grade fentanyl — the largest DEA seizure of the highly potent narcotic in New York history, authorities said Tuesday.

Carlos Ramirez, 25, of Lakewood, Colo ., was arraigned Tuesday in Manhattan Supreme Court on four counts of criminal possession of a controlled substance.

Ramirez was arrested June 19 after agents conducting surveillance spotted him acting suspiciously in the Melrose neighborhood of the Bronx, according to the city’s Special Narcotics Prosecutor.

At 11:40 p.m., he allegedly placed a package wrapped in black tape on the backseat passenger floor of a parked car, officials said.

Agents confronted Ramirez who said he’d just come from room 708 at Umbrella Hotel across the street.

As authorities approached the room, they allegedly noticed a black duffel bag on top of a vending machine and discovered 17 packages filled with what they suspected was heroin.

But lab tests revealed that the beige powder was fentanyl — an opioid 50 times stronger than heroin, prosecutors said.

The haul allegedly contained over 7 million doses of the drug, according to the Special Narcotics Prosecutor.

At the prosecution’s request, Justice Gilbert Hong raised Ramirez’s bail Tuesday from $50,000 bond to $200,000 based on the lab results.

Ramirez’s defense lawyer, Howard Greenberg, blasted the bail hike.

“This is the biggest crock of sh–t in the history of fentanyl,” the attorney said. “It’s just another example of how the special narcotics Nazis throw their weight around in courtrooms in Manhattan seeking gratuitous bail increases.”

Fentanyl — often found mixed with other street drugs, including heroin and cocaine — has become a national scourge.

And the increased use of the powerful drug has driven a spike in fatal overdoses, according to the New York City Department of Health and Mental Hygiene.

“The potential for widespread loss of life was averted only through the investigative skill and fortunate timing of law enforcement officers,” said Special Narcotics Prosecutor Bridget Brennan.