Dayson Sumpter was shot and killed in the Bronx in May 2013.

Costello, now retired, said through the detectives’ union he wouldn’t discuss the allegations.

A source familiar with the case said Costello and other detectives heard from different sources that Martinez was the shooter and that Ward confirmed that, picked him out of a lineup and repeated his story to the grand jury.

But Ward had a vested interest in accusing Martinez — he had just been busted for petty larceny and was told he’d get a good plea deal and $2,000, presumably the Crime Stoppers payout, if he testified, according to the suit.

Martinez said he was playing video games at a friend’s house the night of May 24, 2013, when Dayson Sumpter, 28, was shot dead at West Burnside and Andrews Ave. in Morris Heights, during a marijuana-related confrontation with three men.

The suit contends Costello ignored two witnesses who identified the shooter as “Treezy.” But the source said Treezy was questioned and denied being involved.

It wasn’t until December 2013, when Ward was arrested, that the case was “solved.”

Martinez would remain behind bars for more than 16 months, until May 2015.

But Eric Poulos, Martinez’s defense lawyer, said it was obvious the case was built on a lie.

The gunman in the video the Bronx DA’s office planned to use is short, stocky and muscular, Poulos said — not thin like both Martinez and Treezy.

Poulos also said that shortly after the prosecutor was transferred to another unit, the new prosecutor interviewed Ward.

According to court papers, Ward changed his story, saying he only heard gunfire and did not see Martinez shoot Sumpter. Held at Rikers in an unrelated robbery case, Ward, 24, refused to speak to The News.