Police say 22-year-old suspect in custody after attack on campus that also left four people wounded.

Two people have been killed and four others wounded – two with life-threatening injuries – in a shooting at the University of North Carolina in the United States.

Campus Police Chief Jeff Baker said on Wednesday his emergency dispatch office first received a call about an individual armed with a pistol who had shot several students.

Two or three campus police officers responding to the call entered the building, disarmed the gunman and took him into custody, Baker said.

He was later identified as 22-year-old Trystan Andrew Terrell.

Several local media outlets reported the gunman either was or had been a student on the campus.

BREAKING: Video shows police responding to active shooter at UNCC Charlotte – 6 shot, one in custody. https://t.co/fALK7Apk6F — Breaking News Global (@BreakingNAlerts) April 30, 2019

Initial word of the shooting surfaced in a frantic warning posted by the school on its official Twitter account.

“Run, Hide, Fight. Secure yourself immediately,” the university posted. The school said later on its website the campus was on lockdown and that students and staff should “remain in a safe location”.

The gun violence, coinciding with the last day of classes for the academic year, prompted a security lockdown of the entire campus as police swept the university one building at a time, evacuating students as they progressed.

Video aired on local television and posted to social media showed scenes that have become all too familiar in the United States due to the rise in school gun violence, with students evacuating campus buildings with their hands raised as police officers ran past them toward the scene of the shooting.

Students and faculty file out of buildings with their hands up during a lockdown after a shooting on the campus of University of North Carolina. [Logan Cyrus/AFP]

About three hours after the shooting, Baker said all university buildings had been searched and secured and that students who live on campus could return to their dormitory halls. The university said final exams would be postponed through to Sunday.

Sandy D’Elousa, a spokesperson for the Charlotte-Mecklenburg Police Department, which is leading the investigation, said the suspect in custody was believed to have acted alone. The Federal Bureau of Investigation said its agents were on the scene assisting police.

Television station WBTV in Charlotte, the state’s most populous city, reported that gunfire erupted near the university’s Kennedy Hall administrative building.

“We are in shock to learn of an active shooter situation on the campus of UNC Charlotte. My thoughts are with the families of those who lost their lives, those injured, the entire UNCC community and the courageous first responders who sprang into action to help others,” Charlotte Mayor Vi Lyles said on Twitter.