Two people were killed and four others injured after a campus shooting Tuesday at the University of North Carolina at Charlotte, officials said.

Trystan Andrew Terrell, 22, was charged with two counts of murder and four counts of attempted murder, the Charlotte-Mecklenburg Police Department said early Wednesday.

Police were called late Tuesday afternoon after a gunman shot several students. A suspect was arrested inside an on-campus building, university police Chief Jeffrey A. Baker said.

"I can't tell you the sadness of the entire community to know that a situation like this has occurred on our campus," Baker said late Tuesday. "We are all pretty much devastated."

Three of the injured are in critical condition, according to Baker.

Terrell was also charged with four counts of assault with a deadly weapon with intent to kill, possession of a firearm on educational property and discharging a firearm on educational property, police said. No one else is being sought.

Police received reports of an active shooter in the university's Kennedy Building at 5:42 p.m.

Download the NBC News app for breaking news and politics.

About the same time, the University of North Carolina at Charlotte’s Office of Emergency Management's Twitter account urged people to "Run, Hide, Fight. Secure yourself immediately."

Baker said that "one officer immediately went to the suspect to take him down."

"He said nothing," Baker said, referring to the suspect. "Our officers' actions definitely saved lives, there's no doubt about that."

Trystan Andrew Terrell, 22, is accused of murder. Charlotte-Mecklenburg Police Department

Baker referred to the suspect as "not somebody that is on our radar."

Terrell's grandfather Paul Rold had not heard about the shooting before The Associated Press contacted him, the AP reported. He said his grandson, a UNC-Charlotte student, never showed any interest with guns or weapons.

"You're describing someone foreign to me," Rold told the AP Tuesday night. "This is not in his DNA."

Tristan Field, 19, told NBC News that he was in a classroom in the Kennedy Building where final presentations were taking place when six or seven gunshots rang out from the opposite side of the room.

Field did not see the shooter or hear the gunman say anything. "He just started shooting," Field said. The professor, Field and other students fled to an adjacent building, where they stayed until police escorted them out.

The Alpha Tau Omega fraternity tweeted that Drew Pescaro of the Lamda Delta Chapter was among the injured and under medical supervision. The student-run Niner Times newspaper tweeted that Pescaro is a sports writer at the publication.

Tuesday was the last day of classes at the university, according to WCNC. The university has around 30,000 students, according to its website.

Students and faculty file out of buildings with their hands up after a shooting on the campus of University of North Carolina Charlotte on Tuesday. Logan Cyrus / AFP - Getty Images

Philip Dubois, chancellor of the university, said Tuesday night that while there is much that is not yet known, "we do know that this is the worst day in the history of UNC Charlotte."

"We are a very tight-knit community. Universities are that way. And this really just shakes us to our very core," Dubois added.

The FBI said it was on the scene and assisting the Charlotte-Mecklenburg Police Department and other law enforcement agencies.

Gov. Roy Cooper called the shooting "a tragic day at this great university," and he said "we mourn the loss of life, we pray for those who are being treated at the hospital."

U.S. Rep. Alma S. Adams, D-N.C., tweeted: "I'm devastated by the events at UNC Charlotte. I'm praying for the victims, their loved ones, and the entire UNCC community tonight. This senseless violence has to stop."

CORRECTION (April 30, 2019, 10:35 p.m. ET): An earlier version of this article misspelled the last name of a student who was in a library. She is Jordan Pearce, not Peace.