Investigators at the First Baptist Church on Nov. 7 in Sutherland Springs, Tex., on Nov. 7. (Scott Olson/Getty Images)

The FBI and Apple are bracing for another potential fight over encryption, this time because of the iPhone of the dead gunman in Sunday’s Texas church shooting, according to people familiar with the matter.

The federal government and the company have shied away from open confrontation since a 2016 standoff when the locked and encrypted iPhone of a terrorist in San Bernardino, Calif., led to a major court battle. In that fight, the Justice Department tried to force Apple to unlock the dead man's phone. The company refused, saying to do so would create a security weakness in the phones of all customers.

That legal fight sparked a national debate about the competing interests of national security, law enforcement, personal privacy and giant tech firms. But the larger legal question of whether the government could force companies to provide access to phones and other electronic devices was never answered by the courts, because in the middle of the fight over the San Bernardino phone, the FBI found a private firm that could access it. A similar case fizzled when the suspect suddenly remembered his passcode and provided it to investigators.

On Tuesday, the FBI said it had not been able to access the phone belonging to Devin P. Kelley, the Air Force veteran blamed for killing more than two dozen people at a church in Sutherland Springs, Tex. Officials did not say what type of phone Kelley had, but people familiar with the case said it was an iPhone.

Devin P. Kelley, the suspect in the shooting at the First Baptist Church in Sutherland Springs, Tex. (Texas Department of Public Safety/AP)

After the FBI said it was dealing with a phone it couldn’t open, Apple reached out to the bureau to learn whether the phone was an iPhone and whether the FBI was seeking assistance. An FBI official responded late Tuesday, saying that it was an iPhone but that the agency was not asking anything of the company at this point. That’s because experts at the FBI’s lab in Quantico, Va., are trying to determine if there are other methods, such as cloud storage or a linked laptop, that would provide access to the phone’s data, these people said. They said that process could take weeks.

If the FBI and Apple had talked to each other in the first two days after the attack, it’s possible the device might already be open.

That time frame may have been critical because Apple’s iPhone “Touch ID” — which uses a fingerprint to unlock the device — stops working after 48 hours. It wasn’t immediately clear whether the gunman had activated Touch ID on his phone, but more than 80 percent of iPhone owners do use that feature. If the bureau had consulted the company, Apple engineers would likely have told the bureau to take steps such as putting the dead gunman’s finger to the phone to see if doing so would unlock it. It was unclear whether the FBI tried to use the dead man’s finger to open the device in the first two days.

In a statement, Apple said: “Our team immediately reached out to the FBI after learning from their press conference on Tuesday that investigators were trying to access a mobile phone. We offered assistance and said we would expedite our response to any legal process they send us.”

The two sides have sparred in the past over the first investigative steps involving an iPhone. In the case of the San Bernardino County shootings in December 2016, Apple has said the FBI squandered an early chance to get the data. The gunman in that incident worked for the county government, and the phone in question was his work phone. FBI investigators did not reach out to Apple and instead asked a county technician to reset the shooter’s Apple iCloud password. That foreclosed the possibility of an automatic backup to Apple iCloud servers, which could have been accessed by investigators.

If the FBI is ultimately unable to see the data on the phone, Justice Department officials will be faced with a choice: Is this phone worth another high-stakes legal battle with Apple?

Given the extent of the carnage inflicted by the Texas gunman and the growing problem encryption poses for law enforcement, officials could decide that it is a good test case for their argument that companies should make devices that are accessible with a signed order from a judge.

But that impulse may be tempered by another consideration: So far, it appears the gunman acted alone in what some officials have called a domestic violence problem that escalated into a mass murder.

If there is little reason to think the gunman had accomplices, the Justice Department may have a less compelling argument to try to take Apple to court to force the company to open the phone.

Since the previous cases faded, the Justice Department has shied away from direct public confrontations with Apple and other firms over encryption.

While FBI Director Christopher A. Wray has warned that there are nearly 7,000 phones that cannot be opened and said that such technologies are making it harder to fight terrorism and crime, Congress has shown little interest in tackling the issue.

Law enforcement officials argue that encryption that prevents a police officer from opening a suspect’s phone even with a court order makes it increasingly difficult to solve murders and a host of other crimes. But privacy advocates say that encrypted communications protect everyone from hackers and thieves and that the government should be able to find evidence through other means.

Recently, Deputy Attorney General Rod J. Rosenstein has been speaking out about the issue, which the FBI has called “Going Dark.”

“Unfortunately, some companies are unwilling to help enforce court orders to obtain evidence of criminal activity stored in electronic devices,” Rosenstein said at a speech in Salt Lake City in August. “I hope that technology companies will work with us to stop criminals from defeating law enforcement. Otherwise, legislation may be necessary.”