The encounter happened on a Tuesday afternoon this month, after a motorist caught the attention of a deputy in North Carolina, the News & Observer reported.

That motorist told Wake County Sheriff’s Office Deputy Donnie Farmer that a man had a firearm, and he was pointing it at other drivers on the road. According to the newspaper, when Farmer located the man, he found him armed with a shotgun.

The deputy tried to calm the armed man down, Sheriff Donnie Harrison told WRAL.

“Next thing you know, he’s pointing the gun at him,” Harrison told the station.

Farmer got a hand on the shotgun, though, and was able to keep it from firing. But that wasn’t the end of the confrontation.

The sheriff told the News & Observer that the man then grabbed a handgun from his pocket.

Via the newspaper:

“Deputy Farmer hit the man’s hand” as the gun fired and managed to wrestle the weapon away from him, according to Harrison.

“As a deputy, you don’t ever know what to expect when you’re approaching something like that, so your training kicks in,” Harrison said, according to a CBS affiliate. “And of course when the gun came up, it was automatic to him to get that gun away from him, and he did exactly what he was supposed to.”

The man, 62-year-old William Ray, was charged with assault on a law enforcement officer with a firearm and damage to property, according to Wake County jail records. Ray interrupted a court hearing to deny the allegations against him, WRAL reported.

A message left with his attorney, who reportedly told the court that his client suffered from mental health issues, was not immediately returned.

News of the arrest came as many in the country were again taking a harder look at police tactics and use of force in law enforcement. Last week, two black men were killed during police shootings in Minnesota and Louisiana. Then, on Thursday night, five officers were killed when gunfire rang out during a during a Black Lives Matter protest in Dallas.

As unrest and tension has continued to grow in the days that followed the incidents, hundreds have been arrested as they gathered to protest.

And in the wake of the encounters, actor Jesse Williams was among those who pointed out the contrast in the outcomes of the two fatal shootings and the arrest of Ray, who is white.

It was not immediately clear why Ray was pointing the gun to begin with.

“We’re trying to put the pieces of the puzzle together,” Harrison told WRAL. “To see why he was so angry, why he was pointing guns at people.”

A message left at the sheriff’s office was not immediately returned Monday morning.

“You don’t take any traffic stop, you don’t take any instance, lightly,” Harrison said in WRAL’s report. “And that’s the reason we train, we train, and we continue to train. Because any situation could turn deadly.”