A man who tried to break into an Alabama elementary school was shot and killed during a physical altercation with a school police officer, as communities across the United States remain on the alert for potential attacks after the massacre in Uvalde, Texas.

The man, identified as Robert Tyler White, 32, of Bunnlevel, North Carolina, was fatally shot on Thursday morning outside of the Walnut Park Elementary School in Gadsden, about 60 miles (96 km) northeast of Birmingham, local media reported.

Some 34 elementary-age children were inside the school attending a summer literacy camp when the incident unfolded outside, Gadsden City School Superintendent Tony Reddick told AL.com, a news outlet that covers the state.

"Our primary concern was just making sure that someone who was not authorized to be in our building does not get into it and that our kids are safe," Reddick told reporters.

The incident occurred just over two weeks after a gunman entered Robb Elementary School in Uvalde, Texas, and killed 19 children and two teachers. The massacre has reignited a national debate over U.S. gun laws and has prompted school districts across the nation to check their safety protocols.

In Gadsden on Thursday morning, police responded to the school after receiving a call from a resident who reported a suspicious man trying to open several doors to the building and attempting to get into vehicles in the parking lot, Etowah County Sheriff Jonathon Horton told reporters.

The school resource officer confronted the suspect and a scuffle between the two ensued as White tried to take the officer's firearm. Other officers responded to the incident and the man was shot and killed, Horton said.

"The school resource officer did exactly should be done, he went straight to the threat, confronted it and dealt with it," he said.

None of the officers suffered serious injuries, the sheriff said.

It was unclear why the suspect was at the school and whether he was armed. Officials with the state police, which is investigating the incident, were not immediately available for comment.

(Reporting by Brendan O'Brien; editing by Jonathan Oatis)