A high-ranking NYPD official lied in court while helping to convict an innocent man in a 1995 murder — then sabotaged another cop’s search for the real killers, court papers claim.

Lt. William “Sean” O’Toole, commander of the Bronx Homicide Squad, allegedly committed perjury when he testified at trial about how he nabbed Eric Glisson in the fatal shooting of a livery driver, the documents say.

O’Toole testified that he spotted Glisson, who was wanted for the slaying, in his apartment building and grabbed him just before he dashed inside his pad, court papers state.

But Glisson said the cop used a neighborhood kid to trick Glisson into opening his apartment door.

Glisson and four others — Carlos Perez, Cathy Watkins, Devon Ayers and Michael Cosme — were found guilty in the killing of Baithe Diop and served 18 years in prison before being freed in 2013 on evidence that two gang members were the actual triggermen.

Now, in a legal brief tied to their malicious-prosecution suits against the city, Glisson and the four say O’Toole derailed an investigation that could have led to the real killers, Gilbert Vega and José Rodriguez, nearly 15 years earlier.

A former Bronx detective who worked under O’Toole revealed an informant told him “that Vega and Rodriguez were bragging about killing a livery-cab driver in 1995,” the filing claims.

The detective, Peter Forcelli, said he told O’Toole about the tip in an attempt to find the file on the killing, the papers say.

But O’Toole “remained silent” and didn’t mention Diop’s slaying, even though he “had testified just months earlier at the trial” of Glisson and Watkins, the court papers say.

Forcelli told The Post he recalled the exchange, in late 1997 or early 1998, “like it happened yesterday.”

In court papers, Glisson and the others also claim there’s “ample evidence to infer” O’Toole destroyed the notebook of a detective whose re-investigation of the case led to their exonerations — and which the city admits has disappeared.

“No one would believe that this notebook slipped away accidentally,” said Glisson’s lawyer, Peter Cross.

O’Toole denied the allegations Sunday, saying he “absolutely” hadn’t lied under oath and calling Forcelli’s claims “baloney.”

“There’s no reason for me to hide the notebook or take the notebook . . . Obviously, anyone can put anything they want in court documents,” he said.

“I have nothing to hide and I know I didn’t do anything wrong.”

Additional reporting by Reuven Fenton