PHOENIX — Authorities say a 22-year-old man fatally shot a Phoenix police commander and wounded two other officers as they tried to remove him from a home after his roommates complained he was acting erratically.

Cmdr. Greg Carnicle, a 31-year-old police veteran who was set to retire in the fall, and the two other officers were shot Sunday night as they walked up stairs in the house after Jacob Emry Mcilveen refused to leave, said Phoenix police spokeswoman Sgt. Mercedes Fortune.

Mcilveen remained in the home several hours after the injured officers were removed. He eventually walked out of the home armed with a handgun and was killed by police.

Officer Marissa Dowhan, a three-year police veteran, and Officer Alicia Hubert, who has nearly two years of service, are expected to survive their gunshot wounds, officials said.

It's unclear what erratic behavior prompted Mcilveen's roommates to kick him out.

Fortune said there initially was no indication that things would turn bad. Mcilveen remained calm and cooperative as officers helped Mcilveen carry his belongings out of the home.

But then Mcilveen stopped cooperating as he slammed the door to the house and left the officers outside.

Carnicle, 56, and two other officers then entered the house and were climbing the stairs when Mcilveen came out of an upstairs room and opened fire.

The injuries prevented the officers from getting out of the house, so other officers went inside and helped them out.

Carnicle, who is survived by a wife and four adult children, worked in several positions in the police department, mostly recently overseeing evening and weekend patrol operations.

Phoenix Police Chief Jeri Williams said she was approached last summer by Carnicle about finishing his career as a duty commander for patrol officers.

"It speaks volumes to his tenacity, to his work ethic, to the fact that he was up for being a police officer," said Williams, who knew Carnicle for 30 years. "And that's where he wanted to finish his career."

Britt London, president of the Phoenix Law Enforcement Association, a union representing officers, said Carnicle was his supervisor 20 years ago and demonstrated how he took a genuine interest in the lives of other officers.

When London's young daughter had a health emergency, Carnicle showed up at the hospital with a teddy bear and waited with his family. "That resonated with me for the rest of my career," London said. "You don't find that kind of caring in this tough-guy world that we work in."

Carnicle's family released a public statement through the police department, describing him as a selfless man who was always there for family, friends, fellow officers and others.

"We know he will live on through the character and love he built in our family. We are strong because of him and we will do our best to live to the fullest to honor him," the family said.

The most recent death of a Phoenix police officer in the line of duty was in March 2019, when Officer Paul Thomas Rutherford was struck by a vehicle.

The last officers killed by gunfire were Officer David Van Glasser in May 2016 and Detective John Thomas Hobbs in March 2014.