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.

鈥淏ut 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 鈥渟traightforward 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."

鈥淚t 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.

鈥淚 just don't understand it,鈥 Patricia Campbell told The Boston Globe. 鈥淚t'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.

鈥淎nd 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, 鈥淪top 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 鈥渇irst 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 鈥渓ocked down鈥 with her family during the manhunt and retweeted another post calling Tsarnaev a 鈥減iece 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 鈥淏OSTON 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 鈥減ervasive鈥 media coverage featuring 鈥渂one-chilling still shots and videos鈥 of the bombing and dayslong manhunt required the judge to run a jury selection process 鈥渟ufficient 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 鈥渂ecause 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.

鈥淏y 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.

鈥淚f 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.

鈥淚 see in Boston, where you have the animal that killed so many people during the Boston Marathon,鈥 Trump said. 鈥淭hey 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.