A shocked college community has paid tribute to a “hero” student who died tackling a gunman at the University of North Carolina-Charlotte.

Riley Howell charged at the assailant and knocked him down, buying enough time for the first officer into the classroom to capture Trystan Andrew Terrell, Charlotte-Mecklenburg Police Chief Kerr Putney said.

Mr Howell, 21, was fatally wounded in the effort, along with Ellis Parlier, a 19-year-old student who had studied information technology and computer technology.

Mr Howell was hailed as a hero by stunned friends and family. A runner and former football player, he was “a big, muscular guy with a huge heart”, his family said in a statement.

Riley HowellRiley Howell (Matthew Westmoreland/AP)

The father of his long-time girlfriend, Lauren Westmoreland, said he would have made a fine firefighter or paramedic.

“If what happened in that room is what they say, I completely see Riley doing that,” said Kevin Westmoreland, whose daughter was Mr Howell’s girlfriend of nearly six years. “He was just the kind of person, if someone tripped and fell, he would be the first one to try to help them.”

Mr Howell is likely to have gone through the same active gunman drills as countless other students of his generation. They were taught to run away if they can, hide if they cannot run, and if a gunman prevents those two choices — fight for their lives.

Terrell had a lot of ammunition and while detectives are not sure if he was targeting anyone specifically, they know he picked out the Kennedy Building and gave no indication he was going to stop shooting before Mr Howell charged, Mr Putney said.

“His sacrifice saved lives,” the chief said.

Mr Howell was with classmates for end-of-year presentations in an anthropology class when the shooting happened.

Students during a vigil for the victims at the universityStudents during a vigil for the victims at the university (Chuck Burton/AP)

In a statement, UNC-Charlotte said all the victims were students. The four wounded were Sean Dehart, 20, Drew Pescaro, 19, and Emily Houpt, 23, all of Charlotte; and Rami Alramadhan, 20, from Saudi Arabia.

Terrell, 22, was charged with two counts of murder, four counts of attempted murder and other charges. He is due to make his first appearance in court later.

The motive was not clear. Terrell had been enrolled at the school but withdrew this term, UNC-Charlotte said.

Campus Police Chief Jeff Baker said Terrell had not appeared on their radar as a potential threat.