A 20-year-old student opened fire in a community college classroom, but did not hit anyone and was arrested in a hallway, police said.
No injuries were reported.
Suspected gunman Jason Michael Hamilton was arrested soon after the shots were fired on Tuesday, Sgt Kim Chinn, spokeswoman for Prince William County Police said.
He was charged with attempted murder and discharging a firearm in a school zone and was held without bond. It wasn't immediately known if Hamilton had an attorney.
"The teacher hit the floor when she saw a gun come up," said Chinn.
Chinn said the student, armed with a high-powered rifle that he owned, fired several shots and left the classroom. Officers found him in a hallway where he was cooperative and was taken into custody, Chinn said.
Police have not discussed a motive. "I assume he's upset," Chinn said. "He walked into a classroom and shot at a teacher."
Police received a report of an "active shooting" on the campus on Tuesday afternoon. It quickly prompted fears of another mass shooting like the massacre at Virginia Tech that killed 32 people in 2007.
School officials locked down the campus and SWAT units swept the buildings room by room before letting people leave.