Investigators responded to Stone Hill Middle School in Ashburn around 12:17 p.m. after people reported seeing the man – who has not been identified - enter the school.
Officials placed the school on lockdown after the man was spotted.
The authorities located the man in an empty classroom and took him into custody.
They say he had no prior contact with any students, and the building was only occupied by staff and a small group of students.
Before the incident at the school, deputies were investigating a report of a man trying to break into a location in the 23000 block of Cypress Glen Square in Ashburn.
Investigators are still trying to piece the incident together.
They say additional details will be released later.