For the first time since a high-profile wrongful-conviction scandal exposed his questionable investigative tactics, a retired NYPD homicide detective took the witness stand Wednesday to defend himself over one such case.

Louis Scarcella — who has 71 of his decades-old cases under review by the Brooklyn DA’s Office — was grilled by a lawyer representing Rosean Hargrave, 40, who has been behind bars for 23 years in the killing of a correction officer.

The line of questioning quickly turned to a glaring flaw in Scarcella’s body of investigative work — his repeated use of the same drug-addicted prostitute as a witness in several murders dating back to 1987.

“She was a crack abuser?” Hargrave defense attorney Pierre Sussman asked Scarcella, 62, in Brooklyn Supreme Court. The lawyer was referring to Teresa Gomez, a prostitute the detective admitted using as a witness in “five or six” of his convictions.

“She was a very intelligent girl who spoke three languages,” Scarcella shot back.

“In the throes of a crack addiction?” Sussman pressed.

“Yes, sir,” Scarcella said.

The ex-cop had two civil lawyers in the courtroom making frequent objections on his behalf. One of those lawyers represents him in a case brought by the family of David Ranta, whose 1991 conviction for the murder of a rabbi was overturned last year, ­exposing Scarcella’s shoddy ­police work.

Gomez was a material witness in three Scarcella murder convictions that have already been overturned but she was not a witness in the Hargrave case.

Sussman, nevertheless, pressed Scarcella about Gomez to establish a pattern of allegedly corrupt behavior by the ex-cop that could have extended to his work on the Hargrave case.

“I met Teresa Gomez in Brooklyn at a location I don’t remember,” testified Scarcella.

“I engaged her in conversation and as a result I [brought] her to the 77th Precinct and debriefed her at length in a number of cases.”

Scarcella also testified that he bought Gomez food and gave her money.

He shifted responsibility to the DA’s ­Office when it came to who made arrests.

“During my tenure of 19 years we did not make the arrest. We brought it to the Brooklyn District Attorney’s Office and they authorized the arrest,” he said.

Asked specifically about the Hargrave case, Scarcella often replied, “I don’t ­remember.”

Sussman also questioned Scarcella about the business card the cop shared with his then-partner, Detective Stephen Chmil, which read “Adventurers, marathoners, regular guys, and mountain climbers” along with their names and “Brooklyn North Hom­icide Squad.”

Asked the purpose of the unusual descriptors, Scarcella said, “It was fact that three out of those four were definitely true. The mountain-climber part wasn’t true, but it sounded good.”

After the session, Hargrave relatives and two Brooklyn men who claim Scarcella framed them confronted the ex-cop.

“Scarcella, why you do it? Why you frame us? Why you sending us to jail for something we didn’t do?” yelled Derrick Hamilton, who was paroled in 2011 amid allegations of Scarcella misconduct.