Dzhokhar Tsarnaev

Dzhokhar Tsarnaev

(CNN) — A federal appeals court ruled on Friday to vacate the death sentence of Dzhokhar Tsarnaev, who along with his brother planted homemade bombs near the finish of the 2013 Boston Marathon, killing three spectators.

The US Court of Appeals for the First Circuit ruled to vacate his death sentence on five counts, saying the judge erred several times.

Convictions on three of the counts Tsarnaev was convicted on have been overturned, the three-judge panel said.

But Tsarnaev is not getting out of federal prison.

"And just to be crystal clear: Because we are affirming the convictions (excluding the three § 924(c) convictions) and the many life sentences imposed on those remaining counts (which Dzhokhar has not challenged), Dzhokhar will remain confined to prison for the rest of his life, with the only question remaining being whether the government will end his life by executing him," the opinion, authored by Circuit Court Judge Ojetta Rogeriee Thompson, says.

The court ruled Tsarnaev should be given a new penalty phase trial.

Tsarnaev's attorneys had argued he didn't get a fair trial because Boston was the scene of the mayhem. Attorney Daniel Habib argued in December that the jury was made up of people directly affected by the terror plot who already had made up their mind about Tsarnaev.

Tsarnaev is being held in federal prison in Colorado. He was convicted in 2015, including for the deaths of Krystle CampbellMartin RichardLingzi Lu at the marathon and police officer Sean Collier.

Tsarnaev was 19 years old when he and his brother, Tamerlan, who was 26 years old at the time, went to Boston's Boylston Street shortly before 3 p.m. on April 15, 2013, to carry out their plot.

Surveillance video showed the brothers carrying the pressure cooker bombs in backpacks and moving through the crowd near the marathon finish line in what federal prosecutors called a coordinated attack.

Tamerlan set off the first bomb, a 6-quart pressure cooker that contained gunpowder, nails and BBs, prosecutors said. The bomb killed Campbell, a 29-year-old restaurant manager, and permanently injured several other people who lost their legs.

The second pressure cooker bomb, carried in by Dzhokhar, went off 12 seconds later and killed two people, Martin and Lu, a graduate student from China.

The bombings sparked a manhunt for days that shut down the city. The brothers, while on the run, killed Massachusetts Institute of Technology police officer Sean Collier. After they stole an SUV, the two were chased by police.

Tamerlan died in an explosive firefight with police in nearby Watertown. Dzhokhar was arrested a day later.