TAMPA, Fla. (WFLA) — A police officer was ambushed and shot as he closed in on drug suspect in South Florida on Wednesday, WTVJ reported.

Police said the unidentified officer was conducting a narcotics investigation in Miami-Dade County. He was about to arrest the suspect when he was “ambushed” from behind and shot.

The bullet grazed the back of the officer’s head, but he was not seriously hurt. He was taken to an area hospital and has since been released.

“Thank goodness he’s in good condition, we’re all very blessed that he’s ok,” Miami-Dade Police Director Alfredo Ramirez told reporters Wednesday evening. “This could have been totally different.”

Police said they arrested five people in connection with the shooting. Steve Gallon IV, 32, faces a charge of attempted murder of a law enforcement officer with a firearm, and  Atiba Moore, 30, faces a charge of solicitation to commit first-degree murder. The other three suspects were accused of harboring the alleged gunman after the shooting. Their identities were not released.