Vice President Pence pledged Wednesday to residents of Sutherland Springs, Tex., that the Trump administration would “find out why” a gunman was able to buy firearms in advance of his shooting rampage there despite his violent past and would work with Congress “to ensure that this never happens again.”

“Three days ago, evil descended on this small town and on this small church,” Pence said as he stood on the street in front of First Baptist Church, where 26 churchgoers were killed Sunday by Devin P. Kelley, who should have been barred from purchasing firearms because of a domestic violence conviction while serving in the Air Force.

“He lied on his application. He had a history of mental illness, and there were bureaucratic failures,” Pence said, promising an Air Force investigation of the matter would be completed “in days, not weeks.”

Pence said the Pentagon is also reviewing policies on how such convictions get entered into a national database used to screen gun purchasers.

Pence’s visit — which came while President Trump is on a 12-day trip to Asia — also included a hospital visit with some of those injured Sunday, meetings with law enforcement officials and an appearance at a nearby high school where a prayer vigil was held on the football field.

“The Bible tells us that the Lord is close to the brokenhearted, and that will be our prayer for you, for this whole community,” Pence said before leaving the church for the vigil.

Upon arriving at the high school, Pence, accompanied by his wife, went to the library where dozens of relatives of victims were waiting, many seated at tables.

Pence hugged many of them and asked about their connections to the attack.

“The whole country’s praying over you,” Pence told one man who had lost his sister-in-law. “This church family is touching the whole country.”

“If you would please tell the president we thank him,” a man asked Pence, who replied: “He wanted us to be here. He’s in Beijing, but I guarantee you his heart’s here.”

During the vigil, Pence spoke of the importance of faith in getting through difficult times.

“The voice of faith, the witness of faith in that small church in that small town now echoes across the world,” he said of First Baptist Church.

The vice president urged people in houses of worship across the country to devote prayers on Sunday to the people of Sutherland Springs affected by the rampage.