A Somali refugee and Ohio State University student plowed his car into a group of people who had just evacuated a campus building after a caller reported a gas leak — then slashed them with a butcher knife, leaving nine injured, before he was shot dead, according to officials and a report.

When the attack began, police issued an “active shooter” alert that prompted a campus-wide lockdown and chillingly ordered students to “run, hide, fight.”

A cop was on the scene within a minute and killed the attacker, 18-year-old Abdul Razak Ali Artan, who became a legal permanent resident of the US, NBC News reported.

“He engaged the suspect and eliminated the threat,” OSU Police Chief Craig said.

The mayhem began when the attacker rammed his car into the crowd standing outside Watts Hall about 9:40 a.m.

Jacob Bowers, a sophomore, was sitting on a bench about 100 feet away when he noticed people running for their lives.

“Then I heard someone yell, ‘He’s got a knife!’ And I saw a guy with a big-a−− knife just chasing people around. When I saw that, I grabbed all my stuff and started running,” Bowers told NBC News

The cop yelled to the suspect, “Drop it and get down or I’ll shoot!” before opening fire, Bowers said.

“The man was going insane,” he said.

The chairman of the Department of Materials Science and Engineering told the Columbus Dispatch that students had evacuated the building after someone called in a gas leak.

It was not immediately clear if the leak report was a ploy tied to the attack.

Junior Jerry Kovacich said he witnessed the lunatic trying to run over his classmates and then attack them with the knife after a fire alarm went off, reported The Lantern, OSU’s student paper.

“The guy ended up just coming and hopping the curb with his car and trying to mow down a couple people. He lost control, and I think he ended up hitting three people, and then people were around the car,” Kovacich said.

“Somebody asked him if he was OK, and the guy just hopped out of the car with a butcher knife and starting chasing people around,” he added.

Angshuman Kapil, a graduate student, was outside when the car barreled onto the sidewalk.

“It just hit everybody who was in front,” he said. “After that everybody was shouting, ‘Run! Run! Run!'”

Another student, Martin Schneider, said he heard the car’s engine revving.

“I thought it was an accident initially until I saw the guy come out with a knife,” Schneider said, adding that the attacker was silent during his rampage.

One victim flew into the air and landed on a hard surface after being hit by the car. Another victim, Professor Emeritus William Clark, was slashed in the leg.

Five people were sent to Ohio State Wexner Medical Center, including two who were stabbed and two who were hit by the car, the Dispatch reported.

Two victims with lacerations were sent to OhioHealth Grant Medical Center and two who were struck by the car went to OhioHealth Riverside Methodist Hospital, the paper reported.

One was in critical condition, and the rest were stable, officials said.

“It sounds very fortunate that based on what I heard if this is not a life-threatening injury,” Professor Peter Anderson said. “It’s where we hold our ice cream socials, and then something like this happens.”

Student Sean Cody said he was walking to class near Watts Hall when he heard what sounded like a blast and saw a cloud of dust and about 30 people “booking it” — fleeing from Watts Hall.

He wondered if it was a bomb, then heard what sounded like three gunshots near Watts Hall. The shots heard might have been fired by cops during their pursuit of and encounter with the suspect.

A motive for the bloodshed was not yet known. ISIS militants and al Qaeda have publicly called for supporters to use vehicles as weapons — as an attacker who killed dozens in France did this summer.

Columbus police, state troopers and Franklin County sheriff’s deputies responded as students took to social media to share information and post images from the scene.

Todd Lindgren, a spokesman for the FBI, which is assisting in the probe, said OSU police is the lead investigative agency. The Bureau of Alcohol, Tobacco, Firearms and Explosives also sent agents to the campus.

Campus police lifted a shelter-in-place order about 11:30 a.m. in a tweet that announced: “Scene is now secure.” It also said all classes were canceled for the rest of the day.

“Buckeye Alert: Active Shooter on campus. Run Hide Fight. Watts Hall. 19th and College,” the school’s police and fire department tweeted at 9:56 a.m. — a message which was retweeted by OSU’s main Twitter account.

“Run, hide, fight” is standard protocol for active shooter situations. It means: Evacuate if possible; get silently out of view; or, as a last resort, take action to disrupt or incapacitate the shooter if your life is in imminent danger.

OSU’s main campus in Columbus is one of the largest in the US. The university has more than 65,000 students enrolled across the state.

The school has been in a celebratory mood after its football Buckeyes beat the University of Michigan 30-27 in double OT on Saturday — OSU’s fifth straight victory over the Wolverines.