Top Texas officials this week cited the actions of several armed churchgoers who subdued a gunman in their sanctuary this weekend as a model of how Americans should protect themselves from potential mass shooters.

The attack, after which two church members and the gunman were dead, came two years after the Texas legislature passed a law that authorized anyone with a concealed-carry license to bring their weapon into houses of worship. That law was a response to the 2017 attack on a church in Sutherland Springs that left 26 people dead before a local resident shot the gunman outside the building and forced him to flee.

The shooter who attacked West Freeway Church of Christ in White Settlement, a suburb of Fort Worth, on Sunday was killed by a single shot from church member Jack Wilson, a former reserve sheriff’s deputy and Army veteran. Wilson, who owns a shooting range in nearby Granbury, said he started training fellow members to be a part of the church’s volunteer security team when it launched after the Texas law passed.

“If there is any church in this state, in America, that was prepared for this, it was this church,” Texas Attorney General Ken Paxton, a Republican, said at a news conference Monday. “They had done their training. And I think that you could see it in the results.”

He credited the new law with making the armed congregants’ quick responses possible, calling it a “model of what other churches and other places of business need to focus on.”

President Donald Trump weighed in Monday evening, tweeting that the attack “was over in 6 seconds thanks to the brave parishioners who acted to protect 242 fellow worshippers. Lives were saved by these heroes, and Texas laws allowing them to carry arms!”

But other state leaders took issue with Trump and Paxton’s interpretation of the incident. Former Texas congressman and onetime presidential candidate Beto O’Rourke said the shooting was a reflection of the state’s lax gun-control measures.

“Our representatives in Texas have left us open to these kinds of attacks,” he tweeted. “Time to change our representatives.”

Gun-control activists called out the rate of firearm-related homicides and suicides in the Texas, which ranks in the middle of the pack nationally for gun deaths, according to federal data.

“If more guns and fewer gun laws made Texas safer, it would be the safest state in the US,” tweeted Shannon Watts, founder of Moms Demand Action. “Instead, it has high rates of gun suicide and homicide, and is home to 4 of the 10 deadliest mass shootings.”

The shooter, whom authorities identified as 43-year-old Keith Thomas Kinnunen, fatally shot two members of the church’s volunteer security team, both men in their 60s, during the Sunday service before Wilson fired back at him, officials said.

During a vigil Monday evening, senior minister Britt Farmer said he had encountered Kinnunen at the church before.

“I had seen him. I had visited with him. I had given him food. I had offered him food at other occasions he had been to our building,” he said.

A video of the attack, captured by the church’s live-stream camera, shows the gunman sitting in a pew during the service before the shooting. He stands up and paces briefly before he speaks to another churchgoer and pulls a large gun from his coat at about 10:50 a.m. He then fires toward the man he spoke to, striking him and another man standing nearby, as other congregants scream and dive beneath the pews.

The video then shows a fourth man, apparently Wilson, shoot the gunman. At least four congregants with weapons raised rush toward the attacker, who had fallen to the ground.

The two victims were taken to a hospital but soon died of their injuries. The Texas Department of Public Safety identified the men as Anton Wallace, 64, of Fort Worth and Richard White, 67, of River Oaks.

“We have lost some great men. But so many other lives could have been lost,” Farmer said at the vigil Monday. “I love this community, I love this church, I love this state and I love our country and I love our freedoms. And I’m not going to let evil take that away.”

Footage of the shooting has been removed from church YouTube page, though it continues to circulate through social media platforms.

The FBI is working with local and state authorities to investigate the shooting. Paxton said investigators are uncertain of the gunman’s motive and are searching for people who knew the shooter.

Kinnunen, who had previous arrests for alleged assault, theft and possession of an illegal weapon, appeared to be “more of a loner.”

It is “probably going to be very difficult to determine what his motivations were, other than maybe mental illness,” Paxton said.

Authorities said Kinnunen may have been transient and might have visited the church several times.

“Unfortunately, this country has seen so many of these that we’ve actually gotten used to it at this point,” Jeoff Williams, the regional director of the Texas Department of Public Safety, told reporters Monday. “It’s tragic, and it’s a terrible situation, especially during the holiday season.”

A spokesperson for the West Freeway Church of Christ and Farmer’s family declined Monday to address the church’s security practices. It is unclear whether the church screens people who carry guns into the building.

Farmer recently self-published a work of fiction, set in Texas Hill Country, about an attack on the United States by Muslim terrorists — an event, he writes in the book’s introduction, that he hopes “never comes to pass, but, there is always that possibility.”

As the story begins, a group of Texas ranchers worry forebodingly about the presence of terrorists in the United States. Later, as an Islamic State flag is hoisted atop the Empire State Building, they are glad to have stockpiled guns and ammunition.

“‘Guns needed now,” the main character thinks as the crisis gets underway.

Before the new law, gun owners in Texas could not carry weapons into a house of worship without specific authorization from church leadership. The Sutherland Springs attack spurred Texas lawmakers in a Republican-controlled legislature to loosen the state’s gun laws so that they could do so more easily.

While there is no specific law that allows armed volunteers in places of worship, members of a congregation can use their concealed-carry license to protect their religious community, said South Texas College of Law Houston professor Josh Blackman.

Houses of worship and other businesses in Texas are still legally authorized to ban firearms on their premises. But in September, another law went into effect requiring a house of worship to post a sign stating it is opting out before it can prohibit licensed individuals from carrying weapons inside.

Conservative politicians and gun rights advocates credited the looser gun laws with saving lives.

“The brave officers from the White Settlement Police Department were on the scene in less than two minutes, but these men who had volunteered for the church security team had already secured their church,” Texas Lt. Gov. Dan Patrick, a Republican, said in a statement.

The National Rifle Association renewed its “good guy with a gun” defense of looser firearms restrictions in a Sunday tweet praising the armed churchgoer’s actions — a defense that gun-control group Newtown Action Alliance called a “myth,” noting that Wilson was “highly trained.”

Sen. Ted Cruz, R-Texas, and Texas Gov. Greg Abbott, also a Republican, praised the armed response.

Paxton added Monday: “We can’t prevent every incident, we can’t prevent mental illness from occurring, and we can’t prevent every crazy person from pulling a gun. But you can be prepared like this church was.”