I’m here “to shoot black people . . . I have to do it. You rape our women, and you’re taking over our country. And you have to go.”

Those were the last words members of a historic black church in Charleston, SC, heard from a white gunman before he opened fire and killed nine people, authorities said.

And 14 hours after the bloodbath at the Emanuel African Methodist Episcopal Church, police caught up with Dylann Storm Roof 245 miles away in Shelby, NC. He was armed but went quietly when he was arrested at about 10:50 a.m. in a traffic stop.

Cops tracked Roof, 21, down after a woman on her way to work spotted his car and recognized his distinctive haircut from police surveillance photos.

“I saw the news coverage last night and the picture of the car. I saw the pictures of him with the bowl cut,” Debbie Dills, a worker at Frady’s Florist in Kings Mountain, NC, told The Shelby Star.

“I thought, ‘Nah, that’s not his car.’ Then I got closer and saw that haircut. I was nervous. I had the worst feeling. ‘Is that him or not him?’ ”

Dills followed him for about 35 miles and called her boss, Todd Frady, who alerted Kings Mountain cops.

The police passed the information to cops in Shelby, who made the arrest without incident.

Authorities said he had used an ATM card in Charlotte, about 45 miles from Shelby, so they knew he was in North Carolina.

Charleston Police Chief Greg Mullen said Dills’ tip directly led to Roof’s capture.

“He was stopped because a citizen alerted law enforcement to a suspicious activity, and law enforcement went out, and they knew that once they arrived there that it was the individual that we were looking for,” Mullen said.

Friends said Roof had been planning a mass killing of black people for months and calmly entered the Charleston church during a Bible study meeting at about 8 p.m. Wednesday.

An hour later, Roof stood and announced he was there “to shoot black people,” a law-enforcement source told CNN, citing witnesses.

The killer reloaded five times, even as victims pleaded with him to stop, said a relative of the church’s pastor, the Rev. Clementa Pinckney, who was among the slain.

Pinckney, 41, was also a state senator and personal friend of President Obama.

Roof said to the victims, “I have to do it. You rape our women, and you’re taking over our country. And you have to go,” Sylvia Johnson, a cousin of Pinckney, told NBC News, citing a survivor’s account.

Pinckney, a married father of two, was recently among a group of activists who held a vigil for Walter Scott, a black man fatally shot in the back by a white cop in April. That officer has been charged with murder.

Others slain in church shooting included Cynthia Hurd, 54, an employee of the Charleston County Public Library, which closed its 16 locations Thursday in her honor; Sharonda Coleman-Singleton, 45, a speech therapist and girls’ track-and-field coach at Goose Creek HS and a pastor at Emanuel AME Church; Tywanza Sanders, 26, a graduate of Allen University; and Ethel Lance, 70, a 30-year member of the church.

Also killed were Susie Jackson, 87, Lance’s cousin and a longtime church member; Depayne Middleton Doctor, 49, who retired in 2005 as the Charleston County director of the Community Development Block Grant Program; retired pastor Daniel Simmons Sr., 74, who died in a hospital operating room; and Myra Thompson, 59.

Three people survived, including a 5-year-old child who played dead and a woman kept alive so she could recount the carnage, officials said.

Pals said Roof got a .45-caliber handgun from his dad as a gift for his 21st birthday on April 3.

Roof was taken from police headquarters in North Carolina wearing a bulletproof vest and sick smirk. He waived extradition and was flown back to Charleston Thursday night to face charges.

He is due for a bail hearing Friday but will appear by video link from the Charleston-area detention center where he was jailed. He was expected to be charged with a hate crime.

Victims’ loved ones gathered outside Medical University of South Carolina hospital in Charleston, where the victims were taken.

“I’m lost. I’m lost. Granny was the heart of the family,” Ethel Lance’s grandson, Jon Quil Lance, told The Post and Courier. “What was this guy thinking? That dude shot a bunch of elderly people.”

Obama said he and First Lady Michelle Obama were crushed.

“This is a sacred place in the history of Charleston and the history of America,” he said. “I am confident that the outpouring of unity and strength and fellowship and love across Charleston today from all races, from all faiths, from all places of worship, indicates the degree to which those old vestiges of hatred can be overcome.

With Post Wire Services