LEXINGTON, S.C. — In recent weeks, Dylann Storm Roof reconnected with a childhood buddy he hadn’t seen in five years and started railing about the Trayvon Martin case, about black people ‘‘taking over the world’’ and about the need for someone to do something about it for the sake of ‘‘the white race,’’ the friend said Thursday.
On Thursday, Roof, 21, was arrested in the shooting deaths of nine people during a prayer meeting at a historic black church in Charleston — an attack decried by stunned community leaders and politicians as a hate crime.
In the hours after the Wednesday night bloodbath, a portrait began to take shape of Roof as someone with racist views and at least two recent run-ins with the law. On his Facebook page, the young white man wore a jacket with the flags of the former white-racist regimes of South Africa and Rhodesia.
In an interview with The Associated Press, Joseph Meek Jr. said he and Roof had been best friends in middle school but lost touch when Roof moved away about five years ago. The two reconnected a few weeks ago after Roof reached out to Meek on Facebook, Meek said.
Roof never talked about race years ago when they were friends, but recently made remarks out of the blue about the killing of unarmed black 17-year-old Trayvon Martin in Florida and the riots in Baltimore over the death of Freddie Gray in police custody, Meek said.
‘‘He said blacks were taking over the world. Someone needed to do something about it for the white race,’’ Meek said, adding that the friends were getting drunk on vodka. ‘‘He said he wanted segregation between whites and blacks. I said, ‘That’s not the way it should be.’ But he kept talking about it.’’
Meeks said Roof also told him that he had used birthday money from his parents to buy a gun and that he had ‘‘a plan.’’ He didn’t elaborate on what it was, but Meeks said he was worried — and said he knew Roof had the ‘‘Glock’’ — a .45 caliber pistol — in the trunk of his car.
Meek said he took the gun from the trunk of Roof’s car and hid it in his house, just in case.
‘‘I didn’t think he would do anything,’’ he said.
But the next day, when Roof was sober, he gave it back.
Meek said that when he woke up Wednesday morning, Roof was at his house, sleeping in his car outside. Later that day, Roof dropped Meek off at a lake with his brother Jacob, but Roof hated the outdoors and decided he would rather go see a movie.
Jacob said that when he got in the car, Roof told him he should be careful moving his backpack in the car because of the ‘‘magazines.’’
Jacob said he thought Roof was referring to periodicals, not the devices that store ammunition.
‘‘Now it all makes sense,’’ he said.
Joseph Meek said he didn’t see his friend again until a surveillance-camera image of a young man with a soup-bowl haircut was broadcast on television Thursday morning in the wake of the shooting. Meek said he didn’t think twice about calling authorities.
‘‘I didn’t THINK it was him. I KNEW it was him,’’ he said.
The Southern Poverty Law Center, a civil rights group that tracks hate organizations and extremists, said it was not aware of Roof before the rampage. And some other friends interviewed said they did not know him to be racist.
‘‘I never thought he’d do something like this,’’ said high school friend Antonio Metze, 19, who is black. ‘‘He had black friends.’’
Roof used to skateboard while growing up in the Lexington area and had long hair back then. He attended high school in Lexington and in nearby Columbia from 2008 to 2010, school officials said. It was not immediately clear whether he graduated.
‘‘He was pretty smart,’’ Metze said.
Meek’s mother, Kimberly Konzny, said she and her son instantly recognized Roof in the surveillance camera image because Roof had the same stained sweatshirt he wore while playing Xbox video games in their home recently. It was stained because he had worked at a landscaping and pest control business, she said.
‘‘I don’t know what was going through his head,’’ she said. ‘‘He was a really sweet kid. He was quiet. He only had a few friends.’’
State court records for Roof as an adult show a misdemeanor drug case from March that was pending against him and a misdemeanor trespassing charge from April. Authorities had no immediate details. As for any earlier offenses, juvenile records are generally sealed in South Carolina.
Court records list no attorney for him.
Meek said Roof’s mother and her boyfriend live in Lexington, and his father lives in Columbia.
Roof displayed a Confederate flag on his license plate, according to Konzny, but that is not unusual in the South.
His Facebook profile picture showed him wearing a jacket with a green-and-white flag patch, the emblem of white-ruled Rhodesia, the African country that became Zimbabwe in 1980. Another patch showed the South African flag from the era of white minority rule that ended in the 1990s.
In Montgomery, Alabama, the president of the Southern Poverty Law Center, Richard Cohen, said it is unclear whether Roof had any connection to any of the 16 white supremacist organizations the SPLC has identified as operating in South Carolina.
But Cohen said that based on Roof’s Facebook page, he appeared to be a ‘‘disaffected white supremacist.’’
In a statement, Cohen said the church attack is a reminder that while the post-Sept. 11 US is focused on jihadi terrorism, the threat of homegrown extremism is ‘‘very real.’’ Since 2000, the SPLC has seen an increase in the number of hate groups in the US, Cohen said.
‘‘The increase has been driven by a backlash to the country’s increasing racial diversity, an increase symbolized for many by the presence of an African American in the White House,’’ he said.