It was almost RIP for DMX — who stopped breathing and had no pulse after a drug overdose in the parking lot of a Westchester hotel, police sources said Tuesday.

The 45-year-old rapper collapsed next to a 2016 white BMW outside the Ramada Inn in his hometown of Yonkers at about 6:20 p.m. Monday, police said.

Cops performed CPR on the hard-partying hip-hop star, who has bashed police in his lyrics and interviews.

A medic injected him with Narcan, an anti-opioid used to reverse the effects of a heroin overdose, according to police.

DMX became “semiconscious” and was rushed to a nearby hospital, police said.

A witness and friend of the rapper told cops that DMX (pictured), whose real name is Earl Simmons, had taken a powdered drug before passing out, police said.

“The cops did a great job. They saved [his] life, no doubt about it,” said Lt. Patrick McCormack of the Yonkers Police Department.

DMX in the past has proclaimed, “Cops suck d–k!”

A Ramada clerk, Abraham Chekottu, said, “I saw him leaving the hotel. He looked fine. Then, a few minutes later, a police car came. There was an ambulance, too. Within no time, he left in the ambulance.”

A rep for DMX later claimed the “Party Up” rapper had simply suffered an asthma attack.

But a source familiar with his medical condition fired back, “They’re trying to cover up by saying it was an asthma attack. Obviously, they don’t want to put out that this was an overdose.”

By Tuesday morning, DMX had returned to the hotel and was doing well, according to another clerk there.

DMX has a history of drug possession and legal woes. In October, he was arrested for allegedly failing to pay $10,000 a month in child support, according to the Journal News.

In 2005, he claimed an asthma attack made him hours late to a sentencing hearing.
No drugs were found at the scene on Monday and no criminal charges were filed, police sources said.