A Special Forces soldier entered a closed National Guard armory building in Baltimore County on Monday morning, authorities said, setting off an alarm and starting a standoff with heavily armed police that went on for several hours.

The soldier was safely taken into custody Monday afternoon, Baltimore County police said. They said he is likely to face trespassing charges.

The soldier tripped an alarm at the Gunpowder Military Reservation about 11 a.m., Maryland National Guard spokesman Col. Charles S. Kohler said. The Army called Baltimore County police for help.

Because police didn’t know whether the soldier had access to weapons stored at the armory, they sent a tactical team and a negotiation team.

“The police were taking every precaution,” Kohler said.

The 244-acre facility and training grounds off Notchcliff Road houses a firing range, a navigation course, and obstacles.

The man turned out to be unarmed and did not have access to the weapons, which were locked with a code, Baltimore County police spokeswoman Elise Armacost said. The soldier eventually agreed to come out of the building, Armacost said.

The soldier was sent for a medical evaluation, Armacost said.