A man under arrest was fatally shot Wednesday after trying to grab a sheriff's deputy gun and wounding the officer at a North Carolina hospital, authorities said.

The Cumberland County Sheriff's deputy brought the unidentified man, who was arrested in connection to a home invasion, to Cape Fear Valley Hospital in Fayetteville, Sheriff Ennis Wright told reporters.

"The suspect was picked up last night," Wright said. "The suspect started experiencing medical problems so he was brought to the hospital here."

The Cape Fear Valley Medical Center in Fayetteville, N.C. Google Maps

It so happened that at least one Fayetteville police detective was at the hospital on another case and was able to immediately come to the deputy's side when the struggle started around 8:20 a.m., Fayetteville Police Chief Gina Hawkins said.

"One of the Fayetteville PD's officers was there to help subdue the subject," Wright said. "The subject was shot at that time."

That Fayetteville officer opened fire "and shot the suspect," the police tweeted. "The suspect has been pronounced deceased."

The shootings happened inside the hospital, officials said.

The FBI has been called into lead an investigation into the officer-involved shooting of the suspect, police and deputies said.