Two male students in Virginia have been arrested for plotting a shooting at their high school, law enforcement officials said Saturday.

The teens were planning to call in a bomb threat at Riverbend High School in Fredericksburg, which they attend, and then shoot at students and staff as they evacuated the building, said Capt. Jeff Pearce of the Spotsylvania County Sheriff's office. The students, ages 15 and 17, are being charged with conspiracy to commit murder and are being held without bond at a juvenile detention center, officials said.

Spotsylvania County Sheriff Roger Harris applauded law enforcement officers and school administrators, saying they worked together to successfully thwart the plot.

"We were able to mitigate the danger, long before it presented any chance of coming to fruition and there was no immediate threat to the safety of the kids," Harris said in a statement.

The sheriff's office declined to name the teens, saying it doesn't identify juvenile suspects unless they are charged with a capital felony. Officials say no one else is thought to have been involved in the conspiracy.

A sheriff's deputy who works as a student resource officer arrested the first teen on Oct. 12 after the teen threatened another student via social media, Pearce said. Through that investigation, officials learned about the larger shooting plot and the link to the other student, who was arrested Friday, according to Pearce.

Pearce said authorities discovered the plot by conducting interviews, reviewing communication between the students and their social media accounts. The teens hadn't set a date for the attack, he added.

After searching the teens' homes, authorities said, they found more evidence that allowed them to charge the students with conspiracy to commit murder, Pearce said. He declined to say what kind of evidence was found.