An NYPD detective who was busted for DWI after falling asleep at a red light has slapped the officers who arrested him with a $2 million lawsuit, claiming they lied about the incident so they could make the arrest.

Joseph Oquendo claims that he began dozing in his BMW at a Brooklyn intersection around 6 a.m. after a night out with some pals in May 2011 but had sobered up after having three drinks earlier in the evening, according to the federal court suit.

Cops eventually found him snoozing in the car and charged him with drunk driving after finding an open beer can in the vehicle, the court papers state.

Sgt. Viet Cao reported that Oquendo was slumped over his steering wheel and that they had to bang on his car for several minutes to awaken him, the suit states.

But Oquendo claims Cao embellished his account — and that a surveillance tape of the incident proves it.

Oquendo, who was stripped of his badge and gun after the bust, said the footage shows he was seated upright in the vehicle and that he immediately woke up after a cop tapped on the window.

Cao also reported that Oquendo needed to lean against his vehicle to stand up, but the video shows him walking normally after getting out of the car.

Oquendo was eventually acquitted of DWI at trial by a jury after he presented the contradictory video — and now he wants Cao and a supervising officer, Capt. Daniel Sosnowik, to pay for the incident. he also names the city as a defendant.

“Mr. Cao has a history of providing false testimony in order to justify his arrests of innocent people,” said Oquendo’s lawyer, Frederick Brewington.

Cao was sued last year by a student filmmaker who claimed that he was lawfully filming the front of a police precinct when the officer confronted and arrested him. The charges were eventually dropped and the victim, Justin Thomas, later settled his suit with the city.

Despite being reinstated after his acquittal, Oquendo claims that he was wrongly reassigned from his post after the mess — and that he’s put in for his retirement because of the unfair switch.

“We will review the suit when we are served and respond accordingly,” said a city law department spokesman of Oquendo’s case.