CHARLOTTE, N.C. — A man armed with a pistol opened fire on students in a classroom building at a North Carolina university during the last day of classes Tuesday, killing two people and wounding four others, police said. Officers who had gathered ahead of a campus concert raced over and disarmed the suspect in the room where the shooting happened.

The shooting prompted a lockdown at the University of North Carolina-Charlotte and caused panic across campus as students sheltered in place.

Campus Police Chief Jeff Baker said authorities received a call around 4:40 p.m. that a suspect armed with a pistol had shot several students. He said officers assembling nearby for a concert rushed to the scene, where they apprehended the male suspect. Authorities did not immediately release the suspect’s identity.

“Our officers’ actions definitely saved lives,” Baker said at a news conference.

He said two people were killed, and three remained in critical condition late Tuesday. He said a fourth person’s injuries were less serious.

Monfia Drayton, an adjunct professor, was walking onto campus when she heard the shots ring out. She said she began urging students fleeing the danger to go into a parking deck for cover.

“I heard one final gunshot and I saw all the children running toward me,” she said. “We started to get all the children pulled into the second floor of the parking deck and the rationale was if we’re in the parking deck and there’s a shooter and we don’t know where he is, he won’t have a clear shot.”

She added: “My thought was, I’ve lived my life, I’ve had a really good life, so, these students deserve the same. And so, whatever I could do to help any child to safety, that’s what I was going to do.”

Antonio Rodriguez, 24, who was visiting campus for his friend’s art show, described a chaotic scene.

“Just loud bangs. A couple loud bangs and then we just saw everyone run out of the building, like nervous, like a scared run like they were looking behind,” he said.

Shortly after UNC Charlotte issued a campus lockdown, aerial shots from local television news outlets showed police officers running toward a building, while another view showed students running on a campus sidewalk.

The Charlotte-Mecklenburg Police Department later said that the campus had been secured and that officers were going through buildings to let people who had sheltered in place know that it was safe.

In a tweet, Gov. Roy Cooper praised the officers’ quick response.

“This is a tragic day for Charlotte and this great university,” he said. “We mourn the lives lost and we will all be here to support each other.”

The university has more than 26,500 students and 3,000 faculty and staff. The campus is located northeast of the city center and is surrounded by residential areas.

Spenser Gray, a junior, said she was in a campus building near where the shooting happened watching another student’s presentation when they were alerted to the shooting.

“During his presentation which was on one of the campus computers, a popup came up … that there was an active shooter,” she said, adding that she immediately felt panic and worried the gunman could come to her classroom. “We had no idea where he was … so we were just expecting them at any moment coming into the classroom.”

Susan Harden, an UNCC professor and Mecklenburg County Commissioner, was at home when she heard of the shooting. She went to a staging area, she said, to provide support.

Harden said she has taught inside the Kennedy building, where the shootings occurred.

“It breaks my heart. We’re torn up about what’s happened,” Harden said. “Students should be able to learn in peace and in safety and professors ought to be able to do their jobs in safety.”