SHELBY COUNTY, Alabama - Shelby County Sheriff's officials have charged a 21-year-old gunman in connection with Tuesday's hostage situation at Chelsea Middle School.

Ryan Matthew Sims is charged with five counts of first-degree kidnapping, and one count of making a terrorist threat. He is being held in the Shelby County Jail with bond set at more than $5 million. Sims lives not far from the middle school, where he was a former student and part-time summer employee. His mother, with whom he lives, is a bus driver for Shelby County Schools.

Distraught over a relationship, authorities said, Sims entered the school just after 3 p.m. and went into the locker room, brandishing a gun. As he held the five girls hostage, a PE teacher notified school officials of the emergency in the locker room and the school went into its "Code Red" emergency lockdown plan.

A sheriff's deputy who has stood guard at the school's front door since shortly after the mass shootings in Newtown, Conn., was notified of the hostage situation and ran to the locker room, said sheriff's spokesman Capt. Ken Burchfield. He confronted the gunman, and started to talk with him.

Within about five minutes the deputy, who is a patrol deputy but has training and experience as a school resource officer, talked the man into releasing three of the girls. The conversation continued, and he later released two other girls. Eventually he was able to convince the man to surrender. The school principal was with the deputy every step of the way, Burchfield said. The incident was over in about 20 minutes.

Investigators with the sheriff's office, along with the FBI, the Bureau of Alcohol, Tobacco and Firearms, the Alabama State Troopers and others patrolled the school grounds until they determined no further threat existed. Lawmen worked well into the night, searching the school, the suspect's vehicle, and his home.

Sheriff Chris Curry said today via a press release that he will continue to post deputies at the Shelby County Schools within the sheriff's jurisdiction.