A Philadelphia man who spent nearly two years behind bars on a gun charge that ultimately was dropped has sued the city and former Homicide Detective Philip Nordo, claiming that the ex-officer — who last week was charged with raping male witnesses — knowingly built a false case against him “to curry favor with a new sexual conquest," a man whom Nordo was relying on to testify.

The suit, filed Wednesday in federal court by lawyers for Gerald Camp, also claims that Nordo’s alleged misconduct was the latest example of a long-standing failure by the Police Department to train officers in managing informants.

It cites scandals dating back to the 1980s while alleging the city has been “deliberately indifferent” toward officers making false statements to protect informants, developing inappropriate relationships with them, or coercing or threatening them to provide information — all of which, the suit says, can lead to wrongful convictions.

“These instances demonstrate a policy, practice, and custom among [Police Department] personnel of misusing informants and falsifying paperwork and testimony in furtherance of the cultivation and misuse of informants,” says the suit, filed by attorneys Susan Lin and Jonathan Feinberg.

The suit, which seeks unspecified monetary damages, is the first against Nordo or the city over his alleged misdeeds. A city spokesperson did not provide immediate comment on the suit or its allegations, and Nordo’s criminal defense attorney could not be reached for immediate comment Thursday.

The District Attorney’s Office has been reviewing past convictions connected to Nordo to see if any should be thrown out due to his alleged misconduct.

Camp was arrested in 2015 while Nordo was investigating the shooting death of 22-year-old Eliezer Mendez. According to Camp’s lawsuit, Rhaheem Friend, an informant whom Nordo was cultivating, told the detective he’d left a computer tablet with evidence on it inside a closet in his sister’s house.

Friend also told Nordo a gun was in the closet, according to the suit. But in an “effort to cultivate [Friend] as an informant and sexual conquest” and to protect Friend from prosecution, the suit claims, Nordo and Friend concocted a story pinning the illegal weapon on Camp, who was dating Friend’s sister. As a result, Camp, not Friend, was jailed on firearms charges.

Friend is not named in the suit. But Camp’s criminal defense attorney, Andrew Pappas, a public defender, echoed that chain of events in an interview last week.

Pappas said that Camp, after being arrested, told him about Nordo’s relationship with Friend, and said the two had worked to frame Camp. Although Camp was convicted at trial (thanks in part to testimony by Nordo), Pappas, before sentencing, subpoenaed Friend’s prison phone calls and discovered what he believed to be an inappropriate relationship between Friend and Nordo.

Pappas filed a motion for extraordinary relief in Camp’s case, which the District Attorney’s Office conceded, freeing Camp in April 2017.

It is not clear whether Nordo’s relationship with Friend has anything to do with the charges lodged against Nordo last week because most of the allegations in charging documents have been redacted.

Nordo has pleaded not guilty and is being held without bail. His lawyer said he intends to fight the charges.