Officer Justin Putnam (San Marco Police Department via AP)

A former McAllen police officer was one of three officers shot during a violent incident in San Marcos Saturday night.

Former McAllen police officer Franco Stewart and two others were reportedly shot while responding to a domestic violence call, KVUE reported Sunday.

The attack left 31-year-old Officer Justin Putnam dead and two other officers — Stewart and Justin Mueller — in critical but stable condition, the city’s interim police chief, Bob Klett, said at a news conference Sunday.

Officers Franco Stewart and Justin Mueller (San Marcos Police Department)

The shooter was wearing body armor and waiting to ambush police when they arrived at his home, authorities said Sunday.

“He was prepared, ready for them to come in and started shooting immediately, and there was nothing they could do to escape the gunfire,” Klett said.

Klett tentatively identified the shooter as a 45-year-old local man, Alfredo Perez de la Cruz, but he said he and the Texas Rangers were still working to confirm the man’s identity because he apparently went by different names. His criminal record was not immediately available.

He said that the man wore body armor “as part of his preparation for the officers coming in.”

The officers responded to a 911 call about a man in the apartment who had hit his wife and was threatening other family members who were there.

After speaking with a family member in the parking lot, the officers decided to enter the building because they believed people inside were still in danger, Klett said. The suspect fired on them with a rifle as soon as they entered.

After the initial shooting, a tactical team went into the apartment to confront the attacker and found him dead of an apparent gunshot wound, Klett said. None of the other family members were seriously hurt.

Putnam, who died at the scene, is survived by his fiancee, said Klett, who paused to hold back tears.

“We lost a fine young man, a faithful officer and friend last night,” the chief said. “He understood what it took to police a wonderfully diverse community like San Marcos.”

San Marcos, with a population of about 63,000, is a fast-growing city between San Antonio and Austin. It is home to Texas State University and is known for its outdoor recreational opportunities and its scenic springs and rivers.

Putnam was the second San Marcos officer to die in the line-of-duty, according to city officials. Sgt. Kenneth Copeland was shot and killed while serving a warrant in 2017.

The Associated Press contributed to this report.