The Queens private detective who raped his ex-girlfriend and then framed her for a series of fictional crimes was sentenced to the maximum of 32 years in prison on Wednesday, bringing to a close one of the most bizarre cases to grace a courtroom.

Using knowledge he acquired partly from watching crime dramas like “C.S.I.,” the private detective, Jerry Ramrattan, 39, orchestrated what prosecutors in Queens called one of the most elaborate frame-ups in recent history.

Mr. Ramrattan’s ex-girlfriend, Seemona Sumasar, 36, had accused him of raping her. After she refused to drop the rape charges, he concocted a scheme that landed her in jail for seven months, making it seem as though Ms. Sumasar was the likely perpetrator of a series of brazen armed robberies, for which she was accused of impersonating a police officer.

At his trial in State Supreme Court in Queens, prosecutors produced evidence that Mr. Ramrattan cajoled and extorted witnesses to falsely testify that she had robbed them. He even staged fake crime scenes, prosecutors said, in which he planted evidence, handcuffing one of Ms. Sumasar’s supposed victims to a pole and planting several bullets at the scene of one of the imaginary crimes.

Before Mr. Ramrattan was sentenced on Wednesday, Ms. Sumasar delivered a stinging victim impact statement, noting that he showed no remorse and was so intent on revenge that he would have stopped at nothing to destroy her. “I don’t have words for you,” she said as as he stared ahead, stone-faced, while she spoke. “You are pure evil. You are a sociopath. You need help.”

“Someone needs to put a stop to your madness,” she added.

During her seven months in jail, awaiting a robbery trial, Ms. Sumasar, a former Morgan Stanley analyst, was separated from her young daughter. She lost her business, and her house went into foreclosure. Her bail was set at $1 million, which she could not afford. Mr. Ramrattan, meanwhile, was free until an informant came forward in late 2010 and exposed his plot.

Mr. Ramrattan was convicted in November of a series of charges, including rape, conspiracy and perjury. The nearly monthlong trial offered two opposing plot lines that were seemingly irreconcilable. Prosecutors portrayed Ms. Sumasar as a single mother duped by a wily confidence man intent on malicious vengeance. But the defense characterized her as a dejected lover who had turned on Mr. Ramrattan after he said he was leaving her to return to his wife and family.

Members of the jury said the guilty verdict was predicated on their acceptance of Ms. Sumasar’s account of being bound with duct tape and viciously raped by Mr. Ramrattan, which apparently gave him a motive to create his ruse.

In his plea for leniency, Mr. Ramrattan insisted that he was innocent, saying that he had spent years helping the police solve cases as an informant. “I stand before you with no choice but to accept what is going to happen,” he said. “Think about all the cases I made over the years, the rape victims I assisted. I maintain my innocence.”

Before he was escorted away by police, he added: “There is more to come.” As he spoke, his mother, Shirley Ramrattan, began wailing and was escorted from the courtroom.

His lawyer, Frank Kelly, told the judge that Mr. Ramrattan was not the “monster” he had been made out to be.

But Justice Richard Buchter said Mr. Ramrattan deserved no mercy, calling him a “diabolical conniver and sinister manipulator” who had “shamelessly exploited the criminal justice system.”

The Queens district attorney’s office and the Nassau County district attorney’s office had insisted on Ms. Sumasar’s guilt up until she was freed just weeks before her own robbery trial was set to begin. Ms. Sumasar filed a civil suit in December against the New York City Police Department and the Nassau County Police Department for negligence leading to her wrongful imprisonment..

Justice Buchter railed against the Nassau County police, who had wrongly imprisoned Ms. Sumasar, saying that it did not take “a Sherlock Holmes” to deduce that a 5-foot-2 former Wall Street analyst with no criminal record would not have held people up at gunpoint.

He chastised the police for their egregious handling of the case, saying detectives had “turned a blind eye” to Ms. Sumasar’s protestations that she was innocent and had too easily been taken in by Mr. Ramrattan.

“The police were duped by liars by whom they had a right to be suspicious, and as a result a rape victim was framed by her rapist,” the judge said. “She was victimized by the rapist and then again by the criminal justice system.”

He added: “The defendant is the architect of his own ruin. He deserves no mercy from me, and he won’t get any.”