First his pants were off — and now they’re on fire.

The cop allegedly shot by a jealous New Jersey husband who walked in on the pantless detective with his estranged wife boldly lied to reporters at his house, posing as a “rep” for the NYPD as he fielded questions.

NYPD Officer Louis Pepe, a 16-year veteran assigned to the 63rd Precinct, defended himself in the third person.

“Lou has a flawless record. He’s a great guy. I’ve known him for a long time,” said the cop — sporting a small bruise under his right eye — outside the Staten Island home he shares with his wife. “The family has a lot going on. They are going to let the law proceedings take care of it. The family is not going to give any statement.”

Law-enforcement sources later identified a photo of the man who spoke with reporters as Pepe.

Pepe also apparently hadn’t come clean about being in a relationship with Deborah Dunbar, even as police sources said he was literally caught with his pants down by her estranged hubby, Robert, 35, at her Manalapan home late Friday.

Pepe had been spotted at the woman’s home several times in the last few weeks, her friends said. “She was dating [Pepe],” said a neighbor who asked that her name not be used. “I’d seen him once or twice two weeks ago.”

Dunbar and his wife separated in January, a friend said. She had changed the locks on their home and gotten a restraining order against him, the pal added.

“He still came around. He would drive around this block all the time. It would be all hours of the day and night,” she said.

Dunbar, identified by neighbors as an elevator mechanic, allegedly shot Pepe twice in the right shoulder at 11:30 p.m. Friday after finding his wife and him in the bedroom, law-enforcement sources said.

Dunbar had grabbed the cop’s gun from the nightstand and wrestled the half-naked man to the floor, sources said.

Additional reporting by Jessica Simeone