The Charles County Sheriff's Office said the bullets started flying in a single-family home just after 3:30 p.m. in the 6300 block of Josephine Road in Waldorf.
Sheriff Troy Berry told reporters that a family member of the suspect called authorities for help, prompting his officers to respond. The top boss of the sheriff's office went on to say the alleged gunman inside had an open warrant and was having mental health issues.
Officials did not disclose what the warrant pertained to.
When the officers arrived at the scene, things went from bad to worse.
"The officers got to the upstairs area of the home and was [sic] immediately fired upon, he said.
The two officers were hit multiple times but were able to get out of the house. They returned fire but it was unclear if the alleged gunman was struck, Richardson said.
Both officers were flown to the hospital with serious non-life threatening injuries.
"They did not rush in the house," he said. "They took the necessary precaution but unfortunately, they had to go in the home and engage that individual and at that time, they were ambushed."
Following the shooting, the unidentified suspect barricaded himself inside the home alone. Hours later, authorities used a drone to get a glimpse inside where they found the suspect dead.
"Apparently after the shooting, the front door was left open," Sheriff's Office Public Information Officer Diane Richardson told Fox News.
Officers went into the home and recovered a gun with an extended magazine by the gunman's side, she said.
Authorities are still piecing together whether the suspect died from a self-inflicted gunshot, Richardson said. A cause of death will be determined after an autopsy.