Prosecutors seek the death penalty against Dylann Roof, who killed nine black people at a South Carolina church in 2015.

The white man who shot and killed nine black churchgoers in the US state of South Carolina last year will stand trial in a city already bruised by a former police officer’s racially charged murder trial that ended in a hung jury.

On Wednesday, the jury selection and opening statements are to take place in the death penalty trial of Dylann Roof, who wrote in an online manifesto published shortly before his attack that he was motivated by a desire to “protect the white race”.

Roof sat with 12 people in Bible study and prayer for an hour at Emanuel African Methodist Episcopal Church, in Charleston, on June 17, 2015, before pulling a gun from his bag, firing dozens of shots and reloading several times, police said.

He hurled racist insults, telling the parishioners he was killing them because he wanted a war between whites and blacks, and because blacks were raping white women and taking over the country, authorities said.

Roof left three people alive in the church basement so that they could tell the world his reasons for the shooting, police said.

The shootings took place a little more than two months after a white North Charleston police officer was charged with murder for shooting an unarmed black driver running from a traffic stop, the stark killing unfolding millions of times across the country, online and on television, after a bystander recorded it.

OPINION: White supremacy’s inferiority complex

The trial of Michael Slager ended on Monday without a verdict and, though Charleston stayed calm, tensions rose, even after the state prosecutor promised a retrial.

Although Slager’s lawyers vigorously fought to prove that he was not guilty, Roof’s lawyers have offered several times to plead guilty, if federal prosecutors agreed not to seek the death penalty. They refused.

When prosecutors said it would take six to seven days to make their case that Roof is guilty, defence lawyer David Bruck said Roof’s case would take little additional time.

The past week leading up to the trial had its own drama as Roof fired his lawyers, opting to defend himself, before re-hiring them on Monday. But he said he would again serve as his own lawyer if he is found guilty and the second phase of the trial begins, where prosecutors present evidence that Roof deserves to be executed.

Roof’s attorneys said that they do not know why he wants to be his own lawyer, but said in other cases defendants have been trying to avoid having their lawyers introduce embarrassing evidence that could sway jurors.

Roof faces 33 charges in federal court, including hate crimes and obstruction of religion. State prosecutors plan a second death penalty trial on nine murder charges.