DENVER (Reuters) - A gunman opened fire on sheriff’s deputies at an apartment complex near Denver on Sunday, killing one officer before the suspect was shot and killed, the Douglas County Sheriff’s Office said.

Four other deputies and two civilians were shot and wounded by the suspect, identified as 37-year-old Matthew Riehl, who had had numerous run-ins with the law, according to Sheriff Tony Spurlock.

It was not immediately clear why the incident had escalated, Spurlock said.

“All of them were shot very, very quickly and they all went down almost within seconds of each other,” Spurlock told reporters at a news conference, calling it an “ambush-type” attack.

President Donald Trump said on Twitter: “My deepest condolences to the victims of the terrible shooting in Douglas County @dcsheriff, and their families.”

The deputies first responded to a “verbal disturbance” at the apartment complex in Highland Ranch, about 16 miles (26 km) south of Denver, at about 3 a.m., the sheriff’s office said in a statement.

Two men were in the apartment, and one of them told the officers that the other was “acting bizarre and may be having a mental breakdown,” the statement said. The officers left the scene after determining no crime had been committed.

About 5:15 a.m., officers returned after a second complaint. After they entered the residence, the suspect opened fire from a bedroom, killing Deputy Zackari Parrish, 29, and wounding three others.

Parrish, who was married with two young children, had joined the force seven months earlier.

“When he was shot and went down, the other officers went down right around him and they tried to pull him out, but were unable to because of their injuries,” Spurlock said.

At about 7 a.m., a SWAT team entered the apartment and more shots were exchanged. Riehl was killed and a fourth officer was wounded.

All told, Riehl fired more than 100 rounds before he was shot by police.

The injured officers were identified as Mike Doyle, 28; Taylor Davis, 30; Jeffrey Pelle, 32, and Tom O’Donnell 31. They were taken to hospital and were in stable condition.

Slideshow (3 Images)

Pelle, who had emergency surgery, is the son of Boulder County Sheriff Joe Pelle, according to an online statement from the family.

The identities of the two injured civilians were not immediately disclosed, but Spurlock said he believed they are residents from other apartments. Their injuries were not life- threatening, he said.

The housing complex in an affluent suburban community near Littleton is described on its website as “one of the friendliest apartments” in the area.