Just before closing time on Feb. 28, employees at two stores in a Columbia, South Carolina, mall reported a menacing visitor. The young man, dressed in black, entered both stores and asked the same questions: How many people were working there? When did the store close? And what time did the employees leave?

When a police officer arrived, a security guard pointed out the young man: Dylann Storm Roof.

He was 20 years old and had no criminal record but, the officer later wrote, acted and spoke “very nervously.” The officer arrested Roof for possession of narcotics; he was carrying a prescription medicine intended for people weaning themselves from opiate addiction.

Less than four months later, police say, Roof walked into Emanuel African Methodist Episcopal Church in Charleston. Dressed in a sweatshirt and dark pants despite the early summer heat, Roof sat through a prayer service for almost an hour. Then he pulled a handgun and opened fire. When he left, spouting racial epithets, nine people lay fatally wounded. Among them was the pastor, a South Carolina state senator named Clementa C. Pinckney.

Roof’s path from the erratic episode in the mall to the carnage in the church 200 miles away remained a mystery Thursday, one day after the nation’s latest mass shooting.

Acquaintances described Roof alternately as a shy loner and as a boastful bigot, as a sweet-natured young man and as a pill-popping druggie. The contradictory images suggest that even those closest to Roof may have barely known him.

A roommate, Dalton Tyler, told ABC News that Roof had been “planning something like that for six months.”

“He was big into segregation and other stuff,” Tyler told the network. “He said he wanted to start a civil war. He said he was going to do something like that and then kill himself.”

But a high school friend, Antonio Metze, told The Associated Press: “I never thought he’d do something like this. He had black friends.”

Roof seemed to put little effort into concealing his racist sentiments, in private or in public.

Another friend, Joey Meek, told the AP that Roof had recently complained that black people were “taking over the world” and that “someone needed to do something about it for the white race.”

The few photos that Roof posted on his Facebook page implicitly followed that theme.

In one photo, Roof stands beside a cypress swamp, framed by Spanish moss, his face twisted into a scowl. He wears a black jacket sporting flag insignias of two African countries formerly ruled by oppressive white minorities: Rhodesia, now known as Zimbabwe, and Apartheid-era South Africa.

The Anti-Defamation League said in a statement Thursday that both flags have become popular symbols for white supremacists worldwide. Roof was not known to belong to any such organizations, however.

In the other two Facebook photos, Roof sits on the hood of his black Hyundai sedan – the car he was driving when he was arrested in Shelby, North Carolina. An unofficial license tag on the front bumper reads, “Confederate States of America.”

Roof grew up mostly in Lexington, South Carolina, but may have lived elsewhere at times after his parents divorced. More recently, Roof lived in a rural community on the outskirts of Columbia, the state capital. The house, built of logs, sits among a few others near the town of Eastover. A large American flag is draped from the top of the front porch. No one answered the door of the house Thursday.

On Facebook, Roof said he attended White Knoll High School in Lexington, but a school district spokesperson said he dropped out in the 10th grade. Officials couldn’t determine whether he completed high school elsewhere.

At White Knoll, Roof was “kind of wild,” classmate John Mullins told The Daily Beast. “He used drugs heavily a lot. He was like a pill popper, from what I understand. Like Xanax, and stuff like that.”

An uncle, Carson Cowles, told the Reuters news agency that Roof was withdrawn and obviously troubled.

When he was 19, “he still didn’t have a job, a driver’s license or anything like that, and he just stayed in his room a lot of the time,” Cowles said.

But in April, for his 21st birthday, Roof’s father gave him a .45-caliber handgun, Cowles said. “Nobody in my family had seen anything like this coming.”

It is not known whether that is the gun Roof carried into the church Wednesday.

It also is not clear whether Roof’s family knew about his arrest at Columbiana Centre mall.

A Columbia police officer approached Roof following complaints from employees at two stores, the Shoe Warehouse and Bath and Body Works.

In a report, Officer Brandon Fitzgerald wrote that Roof “began speaking very nervously and stated that his parents were pressuring him to get a job.”

Roof acknowledged he had not applied for jobs at the stores he had visited. As Fitzgerald asked more questions, Roof “was becoming more nervous-acting and taking more time to think of answers,” the officer wrote. Roof consented to being searched, and Fitzgerald said he found an unlabeled bottle containing Suboxone, a medication that simulates the effects of opiates. Roof acknowledged he had no prescription for the medicine.

Roof was arrested on a felony drug-possession charge. The case is pending.

The mall barred Roof from its premises for a year, but he returned on April 26. A police report contains few details of the incident, but Roof was arrested for trespassing, a misdemeanor.

“He returned to the place where we had said, ‘Don’t come back,’’’ said Jennifer Timmons, a spokeswoman for the Columbia police.

Authorities have not said whether Roof gave a statement following his arrest. Roof could be glimpsed only briefly Thursday as officers escorted him to a patrol car in North Carolina. By then, he had changed into a white T-shirt and a blue flak jacket. His long blond bangs covering his forehead, Roof looked directly at news photographers with a blank expression. The angry scowl from his Facebook photos was gone.