ASHEVILLE, N.C. — A deputy was shot outside the magistrate’s office in Buncombe County early Sunday morning while trying to serve a warrant, the Buncombe County Sheriff’s Office said.

It happened at about 1:45 a.m.

While a woman was filing a protective order and the deputy was securing warrants, the suspect involved walked into the magistrate’s office, which is in the lobby of the Buncombe County Detention Facility.

The deputy and a police officer tried to arrest the man, but officials say he resisted.

That’s when deputies say the suspect pulled out a gun and shot the deputy in the shoulder.

“The deputy returned gunfire and struck the suspect, who subsequently fled the scene and was later taken into custody outside Mission Hospital,” deputies say. An Asheville police officer was also hurt but is expected to be OK.

The deputy went to the hospital and is now resting at home. The suspect is under observation at Mission Hospital.

The magistrate’s office was closed Sunday morning.

The State Bureau of Investigation is investigating.