Prosectors introduced and played Dylann Roof's two-hour video confession during the third day of Roof's federal death penalty trial. (U.S. District Court for the District of South Carolina)

Dylann Roof was calm — laughing at times — when he confessed to the massacre of nine black parishioners inside a South Carolina church.

He was nonchalant when he explained to FBI agents why he chose to gun down the six women and three men inside the historic black church in Charleston. He knew there would be a group of black people inside, he said.

With a few swift motions of his right arm, Roof demonstrated how he pulled out his Glock .45-caliber pistol and fired — 77 total shots. He talked about sitting inside with the churchgoers for about 15 to 20 minutes as he briefly questioned what he was about to do.

The confession was revealed for the first time Friday, the third day of Roof’s federal death penalty trial. Prosecutors introduced and played Roof’s two-hour video confession, obtained several hours after the June 15, 2015, bloodbath. The Post and Courier posted the video online.

“Well yeah, I mean, I just went to that church in Charleston and, uh, I did it,” Roof told agents when they asked him to tell them what happened.

Roof wavered briefly when the agents asked him to describe exactly what he had done.

“Well, I killed them, I guess,” Roof said.

When one of the agents asked whether he knew how many people he had shot, Roof said, “Five maybe? I’m really not sure, exactly.”

Roof was quick to explain his reason for his actions.

“I had to do it because somebody had to do something,” he said. “Black people are killing white people every day on the street, and they are raping white women. What I did is so minuscule to what they’re doing to white people every day all the time.”

Prosecutors also introduced Roof’s handwritten journal as evidence. He chronicled how he began researching about race. He wrote about how Trayvon Martin’s death had prompted him to begin absorbing information online. He dedicated a lengthy section about blacks whom he described as “the biggest problem for Americans.”

Dylann Roof, the white man who has confessed to killing nine black church-goers in Charleston faces the death penalty if convicted. On Dec. 8, a jury watched surveillance video of Roof entering and leaving Emanuel African Methodist Episcopal Church on June 17, 2015, the night of the massacre. (Reuters)

“Segregation was not a bad thing. It was a defensive measure,” he wrote, explaining that it was meant to “protect” white people from black people. “And I mean that in multiple ways. Not only did it protect us from having to interact with them, but it protected us from being brought down to their level.”

Roof’s trial began Wednesday, about a year and a half after the killings at Emanuel African Methodist Episcopal Church. Roof, now 22, is charged with 33 counts of federal hate crimes. The victims were gunned down during a Bible study.

“Little did they know what a cold and hateful heart he had,” Assistant U.S. Attorney Jay Richardson told jurors.

Felicia Sanders, one of only three survivors of the attack, looked directly at Roof, her face covered with tears, as she testified.

“The defendant over there, with his head hanging down, refusing to look at me right now, said, ‘I have to do this because y’all are raping our women and taking over the world.’”

“That’s when he put about five bullets in my son,” Sanders said. Tywanza Sanders, 26, was one of the male victims.

Sanders said the Bible study group had welcomed Roof that day, thinking he was someone who “was looking for the Lord.”

During the trial, which is expected to resume Monday, Roof did not look at the dozens of victims’ family members in the room.

His defense team has largely conceded that he’s guilty and has, instead, tried to focus on sparing him the death penalty, according to the Associated Press.

In his taped confession, Roof told the agents that he had planned to shoot himself, too, but he decided against it after police officers didn’t show up right away.

Roof’s trial began shortly after a federal judge ruled last month that Roof is competent to stand trial. The decision means that he understands the nature of the proceedings against him and can assist in his own defense.

Kevin Sullivan and Matt Zapotosky contributed to this report.

Dylann Roof pleaded guilty April 10 in the state court trial, avoiding a second death-penalty trial. In January, a federal court sentenced Roof to the death penalty for killing nine black parishioners at the Mother Emanuel Church in Charleston, S.C., in 2015. (Gillian Brockell,Monica Akhtar,Bastien Inzaurralde/The Washington Post)

READ MORE:

A look inside the trial of Dylann Roof

Accused Charleston church shooter Dylann Roof competent to stand trial, judge rules

What happens next if Dylann Roof is sentenced to death