Updated

The rifle-toting man who gunned down a Colorado deputy in a New Year’s Eve “ambush-style” attack had ranted about the sheriff and a local police officer in recent online posts discovered after the assault.

Matthew Riehl, 37, fired more than 100 rounds as he was holed up in a bedroom in his apartment in Highlands Ranch, before he too was found dead at the scene. The Douglas County Sheriff's office identified Riehl as the gunman Sunday evening.

Three other deputies, a police officer and two civilians were also wounded. The deputies and the officer had gone to the apartment around 5:15 a.m. in response to a disturbance, Douglas County Sheriff Tony Spurlock said. They had been to the apartment about an hour earlier.

“They all went down, almost within seconds of each other,” Spurlock said.

apartmentcomplex1

The Douglas County Sheriff's Office says five deputies were shot at an apartment community in Highlands Ranch, Colo. (Fox 31 Denver)

He said the deceased deputy was 29-year-old Zackari Parrish. He had been a deputy for seven months.

“I can’t tell you how difficult it is for a leader to sit down with a spouse of an officer who was killed in the line of duty,” Spurlock said. “They had many hopes and dreams. He was doing his job and he was doing his job well.”

Parrish is survived by his wife and two children and previously worked for two years at the Castle Rock Police Department.

Riehl, who was killed, was an Army veteran who served briefly in Iraq, Fox 31 Denver reported.

He is seen wearing an Iraq combat veteran hat in a Dec. 13 YouTube video in which he called Spurlock a “clown” and a deputy a pimp.

“You know who’s going flub big time next election, Spurlock,” Riehl said in the video called “Fire Sheriff Spurlock.”

He said he was running against Spurlock as a libertarian.

A video posted on Nov. 28 showed a traffic stop by a police officer in the city of Lone Tree — apparently taken inside the officer's car — that Riehl said was done illegally. He claimed the officer clocked the wrong driver, identifying the officer by name in the video and calling him "dirty."

"S---bag, dirtbag, liar," he says as the officer questioned the driver. "He's the boss, huh? He's the Nazi in charge with the stripes on his shoulder and the fake badge."

The wounded officers: Deputies Mike Doyle, 28; Taylor Davis, 30; and Jeffrey Pelle, 32; and Castle Rock police officer Tom O’Donnell, 41, were said to be in stable condition. The civilians had suffered non-life threatening injuries, Spurlock said.

Pelle is the son of Boulder County Sheriff Joe Pelle, Fox 31 Denver reported.

Authorities had been to Riehl's home earlier in response to a complaint of a "verbal disturbance" involving two men, the sheriff's office said. One of the men told them the suspect "was acting bizarre and might be having a mental breakdown" but the deputies found no evidence of a crime.

When deputies were called back, a man who had left came by to give them a key and granted permission to enter the home, leaving again before shots were fired.

"The suspect was just making a ton of noise and annoying everyone around him," Spurlock said.

Four officers, including Parrish, were shot from a bedroom around 6 a.m., forcing the retreat. A SWAT team entered the apartment at about 7:30 a.m. in an exchange of gunfire that left the gunman dead and another officer injured.

Local media reported gunshots being heard amid a stream of firetrucks and emergency vehicles entering the area.

Steven Silknitter, who lives in the complex, told the Denver Post that he was working elsewhere when he got word of the shooting and called home to speak to his fiance.

“She was pretty scared,” Silknitter said. “She kept saying how loud it was.”

President Donald Trump tweeted that he has offered his “deepest condolences to the victims of the terrible shooting.”

Colorado Gov. John Hickenlooper also issued a statement saying “our thoughts and prayers” were with the Douglas County Sheriff's Office and the family and friends of Deputy Parrish.

"We can only imagine the depth of grief they are experiencing,” he said. "We also hope for a speedy recovery for the Douglas County deputies and the Castle Rock police officer injured in the incident, as well as the residents who also were affected.

He added, "The call to protect and serve too often leads to this ultimate sacrifice. We are grateful for the service of Deputy Parrish, his fellow deputies, and that of the Castle Rock police officer.  We pray for their and their families' strength and resolve in the days and months ahead."

The Associated Press contributed to this report.