CHARLOTTE, N.C. — A former student opened fire in a classroom building at a North Carolina university on Tuesday night, killing two people and injuring four others as students finished the last day of classes before final exams and prepared for a campus concert.

Police disarmed and apprehended the suspect in the room where pistol shots rang out, said Jeff Baker, police chief at the University of North Carolina at Charlotte, crediting the officers' actions with saving lives.

“This is a truly tragic day," Baker said. "It is something where everyone says ... God, I hope this doesn’t happen. But it happened.”

Three of the injured were in critical condition at local hospitals and the fourth was stable, Baker said. Police on Tuesday night identified the shooter as Trystan Andrew Terrell, 22, who, according to school records, was last enrolled in fall 2018.

What we know:Here's what we know about the University of North Carolina at Charlotte shooting

UNC Charlotte:What to know about campus

The victims have not been identified, pending family notification, police said.

"This is the worst day in the history of UNC Charlotte," said Chancellor Philip L. Dubois.

The UNC Charlotte emergency lockdown alert interrupted the final presentation of graduate student Manal Naim. She said she thought it was a drill.

“We thought they were testing the network,” she said.

Authorities swept through buildings looking for students and staff sheltering in place late into the night. An alert asked students to follow officer commands and for others to stay away from campus until an all clear is given.

Jennifer Bailey was waiting to reunite with her daughter, a student at the university. Her daughter, at the time, was locked in an office with 11 other students, she said.

“It’s the worst feeling ... when that text comes,” she said. “I’ve never felt so helpless.”

Shots were fired at a building on campus at approximately 4:40 p.m. EDT, university officials said. Tuesday marked the last day of classes before final exams set to begin Thursday. The university cancelled exams through the end of the week, Dubois said, and it was unclear when exams would resume.

“We know that for many people, this will be the worst day of their lives," said Gov. Roy Cooper, who flew to Charlotte on Tuesday night after hearing news of the shooting. "Students should not have to fear for their lives on our campuses. ... This violence has to stop.”

UNC Charlotte freshmen Joy Armstead, Trinity Sturlark and Exon Diaz were waiting at a strip mall Tuesday night for a shuttle bus to take them back to campus. They were leaving campus to sell clothing at a consignment store at the time of the shooting.

While she has heard about shootings at other schools, Armstead said she never expected such an event at her campus.

“It's just weird. It's just like a different feeling I've never felt before," she said. “I was too shocked to say anything.”

Sturlark had a similar reaction: “It is hard to process,” she said.

No other suspects were involved, The Charlotte-Mecklenburg Police Department tweeted. The FBI was on the scene late Tuesday night to "provide any resource needed as the investigation continues to determine exactly what led to this tragic loss of life in our community," said John Strong, special agent in charge of FBI Charlotte.

Susan B. Harden, a county commissioner and education professor at UNC Charlotte, said she talks about shootings frequently while training teachers. Still, Harden was rattled.

“I’m stunned and heartbroken,” she said. “This is not what’s supposed to happen in an educational setting.”

More:UNC Charlotte is latest in a string of North Carolina campus shootings

To reunite students with their families, the police told people to meet in a shopping center directly across the street from campus. The campus remained closed late Tuesday, but police drove students to various buildings to retrieve their belongings. While fleeing campus, students left their cell phones and car keys in classrooms.

"We are in shock to learn of an active shooter situation on the campus of UNC Charlotte," Charlotte Mayor Vi Lyles said on Twitter. "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."

UNC Charlotte has more than 26,500 students and 3,000 faculty and staff.

A free Waka Flocka Flame concert at the school's football stadium was scheduled for 6 p.m. local time, shortly after gunshots were reported.The concert was cancelled, and the rapper reported himself safe on social media.

Contributing: Kirk Brown and Nikie Mayo, Anderson (S.C.) Independent Mail; Mollie Simon, Greenville (S.C.) News; The Associated Press