It was all legal-ish.

The partner of embattled former NYPD Det. Louis Scarcella admitted in court Wednesday that the men may have blurred the lines on proper police work sometimes — but maintained they never did anything illegal.

“We used some questionable tactics,” retired NYPD officer Stephen Chmil admitted during a Brooklyn Supreme Court hearing into whether or a judge should overturn Eliseo DeLeon’s murder conviction.

While Chmil did not explain what he meant by “questionable tactics, he also said the duo “might” violate police procedure to secure a confession.

Yet when explicitly asked by defense attorney Cary London if they engaged in “illegal practices,” Chmil resolutely answered “none, sir.”

“So the alleged oral statement he confessed to the crime and the video statement he denies the crime?” London asks Chmil.

“That’s correct,” he responded.

DeLeon claims Scarcella and Chmil fabricated his murder confession, which Scarcella adamantly denied during his own testimony last month.

DeLeon was convicted in 1996 of fatally shooting Fausto Cordero in the stomach during a Clinton Hill Robbery. He’s serving 25 years to life for the slaying.

Fourteen cases from the 1980s and ’90s worked by Scarcella — and occasionally Chmil — have been vacated. Eight were overturned by the Brooklyn DA’s Conviction Review Unit, while another six were thrown out by judges considering defense motions.

Scarcella’s lawyers say he played a minor role in DeLeon’s case, and didn’t testify at his trial.

The former detective adamantly maintains he never acted improperly on any case, and even lashed out at London during his last turn on the witness stand.

“Why are you asking me those questions?” he yelled at the defense attorney in June.

The Brooklyn DA’s office stands behind DeLeon’s conviction.

He’s due back in court July 16 for more hearings.

—Additional reporting by Daniel Cassidy