A federal appeals court Friday threw out Dzhokhar Tsarnaev's death sentence in the 2013 Boston Marathon bombing, saying the judge who oversaw the case did not adequately screen jurors for potential biases.

A three-judge panel of the 1st U.S. Circuit Court of Appeals ordered a new penalty-phase trial on whether the 27-year-old Tsarnaev should be executed for the attack that killed three people and wounded more than 260 others.

“But make no mistake: Dzhokhar will spend his remaining days locked up in prison, with the only matter remaining being whether he will die by execution,” Judge O. Rogeriee Thompson wrote in the ruling, more than six months after arguments were heard in the case.

An attorney for Tsarnaev said they are grateful for the court's “straightforward and fair decision: if the government wishes to put someone to death, it must make its case to a fairly selected jury that is provided all relevant information.”

“It is now up to the government to determine whether to put the victims and Boston through a second trial, or to allow closure to this terrible tragedy by permitting a sentence of life without the possibility of release,” David Patton said in an email.

A spokesperson for the U.S. Attorney's office in Boston said they were reviewing the opinion and had no immediate comment. Prosecutors could ask the full appeals court to hear the case or go straight to the U.S. Supreme Court.

The mother of Krystle Campbell, the 29-year-old killed in the attack, expressed outrage at the court's decision.

“I just don't understand it,” Patricia Campbell told The Boston Globe. “It's just terrible that he's allowed to live his life. It's unfair. He didn't wake up one morning and decide to do what he did. He planned it out. He did a vicious, ugly thing.”

Former Massachusetts Bay Transportation Authority officer Dic Donohue, who was severely injured in a gunfight with the brothers, said the ruling was not surprising to him.

“And in any case, he won't be getting out and hasn't been able to harm anyone since he was captured,” he tweeted.

Tsarnaev's lawyers acknowledged at the beginning of his trial that he and his older brother, Tamerlan Tsarnaev, set off the two bombs at the marathon finish line. But they argued that Dzhokar Tsarnaev is less culpable than his brother, who they said was the mastermind behind the attack.

Tamerlan Tsarnaev died in a gunbattle with police a few days after the April 15, 2013, bombing. Dzhokar Tsarnaev is now behind bars at a high-security supermax prison in Florence, Colorado.

Tsarnaev was convicted on 30 charges, including conspiracy and use of a weapon of mass destruction. The 1st Circuit upheld all but a few of the convictions.

Prosecutors told jurors that the men carried out the attack to punish the United States for its wars in Muslim countries. In the boat where Tsarnaev was found hiding, he had scrawled a confession that referred to the wars and wrote, among other things, “Stop killing our innocent people and we will stop.”

Tsarnaev's attorneys identified a slew of issues with his trial, but said in a brief filed with the court that the “first fundamental error” was the judge's refusal to move the case out of Boston. They also pointed to social media posts from two jurors suggesting they harboured strong opinions even before the 2015 trial started.

One juror had said in Twitter posts that that she was “locked down” with her family during the manhunt and retweeted another post calling Tsarnaev a “piece of garbage,” but later told the court she had not commented on the case or been asked to shelter in place, the defence said. On the day of Tsarnaev's sentencing, the juror changed her Facebook profile picture to an image that said “BOSTON STRONG,” a rallying cry used in the wake of the bombing, the attorneys said.

Tsarnaev's lawyers pushed several times to move the trial out of the city where the bombs exploded, arguing the intense media scrutiny and number of people touched by the attack in Boston would taint the jury pool. But U.S. District Judge George O'Toole refused, saying he believed a fair and impartial jury could be found in the city.

The 1st Circuit said the “pervasive” media coverage featuring “bone-chilling still shots and videos” of the bombing and dayslong manhunt required the judge to run a jury selection process “sufficient to identify prejudice.” But O'Toole fell short, the judges found.

The judges said O'Toole deemed jurors who had already formed the opinion that Tsarnaev was guilty qualified “because they answered `yes' to the question whether they could decide this high-profile case based on the evidence.” Yet he didn't sufficiently dig into what jurors had read or heard about the case, it said.

“By not having the jurors identify what it was they already thought they knew about the case, the judge made it too difficult for himself and the parties to determine both the nature of any taint (e.g., whether the juror knew something prejudicial not to be conceded at trial) and the possible remedies for the taint,” Thompson wrote.

All three judges agreed that the death sentence should be tossed. In a concurring opinion, Judge Juan Torruella wrote that the case should never have been tried in Boston.

“If this case did not present a sufficient basis for a change of venue, there are no set of circumstances that will meet this standard, at least not in the First Circuit,” he wrote.

President Donald Trump weighed in on the ruling during an address to supporters on the tarmac of Tampa International Airport.

“I see in Boston, where you have the animal that killed so many people during the Boston Marathon,” Trump said. “They just sent this conviction for the death penalty back to the lower courts so they'll argue about that for a long time. It's ridiculous.”

Durkin Richer reported from West Harwich, Massachusetts.