A jury had decided on the death penalty for Ronell Wilson in July. The judge pronounced the sentence in Brooklyn federal court on Tuesday.
It was the latest chapter in a case that's seen his original death sentence overturned, his behind-bars affair with a prison guard exposed and the massive cost of his defense questioned.
Wilson will die by lethal injection, pending yet another appeal process.
He will now be moved to the federal penitentiary in Terre Haute, Indiana, to await execution.
Another jury had found Wilson guilty in the point-blank shootings of undercover officers James Nemorin and Rodney Andrews. The gunman shot both men in the head after one pleaded for his life.
"Wilson's death sentence marks the end of a ten-year odyssey in the relentless pursuit of justice," said United States Attorney Loretta E. Lynch. "This sentence follows the recommendation of a jury of Wilson's peers that justice requires the imposition of the ultimate punishment for the vicious and senseless murder of two husbands, two fathers and two protectors of the City of New York. With this sentence, we can only hope that the families of New York City Police Detectives Andrews and Nemorin will take some comfort in its finality."
The first jury also sentenced Wilson in 2007 to die by lethal injection, making him the first federal defendant to receive a death sentence in New York City since the 1950s. But an appeals court threw out the sentence in 2010 and prosecutors chose to repeat the penalty phase rather than let Wilson serve an automatic life term.
U.S. District Judge Nicholas Garaufis questioned the decision, saying that it put taxpayers on course to spend millions of dollars more on Wilson's defense. He noted that he had just presided over a capital case for a mobster where the defense bill was $5 million and the jury chose to impose a life sentence.
Officials revealed in February that, after being transferred from federal death row in Indiana to a Brooklyn lockup to await the proceedings, the 31-year-old Wilson fathered a child with a jail guard. She's since pleaded guilty to an illegal sex act.
The new set of jurors, though not deciding Wilson's guilt, once again heard about how the victims were posing as illegal gun buyers. The pair met with Wilson for what they thought was a deal to buy a Tec-9 submachine gun. But Wilson decided to rob them instead and ended up shooting them.
Prosecutors cited a scrap of paper Wilson was carrying when he was arrested as proof he was a cold-blooded killer. It had the rap lyrics saying that if he was ever crossed, he would put "45 slugs in da back of ya head" and "ain't goin stop to Im dead."
The government also argued that Wilson's conduct behind bars, including having sex with the jail guard and threatening a gay inmate, made him a bad candidate for a life term.
In asking to spare his life, Wilson "wants you to use your humanity," said Assistant U.S. Attorney Celia Cohen said in closing arguments. "He has shown through his actions that he has absolutely no humanity."
The defense conceded Wilson had committed a horrible crime. Wilson's lawyers instead sought to focus jurors on his background as the product of a crack-addicted mother living with a dozen relatives crammed into an apartment at a crime-infested housing project.
Defense attorney David Stern argued that a life sentence was sufficient punishment for a "limited" and "impulsive" defendant who was never taught right from wrong.
"One day he'll die wearing the same khaki clothes he's worn for 20 or 30 or 40 years," Stern said in closing arguments.
(The Associated Press contributed to this report)