The authorities in the eastern German state of Saxony struggled to explain on Thursday how a Syrian refugee suspected of planning an imminent terrorist attack had been able to kill himself in his jail cell, saying “we did everything possible to prevent it.”

The suspect, Jaber al-Bakr, 22, apparently hanged himself with his T-shirt. His death is almost certain to add to pressure on the state and federal authorities to improve coordination among the patchwork of agencies responsible for law enforcement.

Mr. Bakr, who was taken into custody by the police early Monday after he was turned in by other Syrian refugees, averted a first attempt by the security services to capture him on Friday. He committed suicide Wednesday night in his Leipzig jail cell, a spokesman for the Justice Ministry in Saxony said.

“This should not have happened,” said Sebastian Gemkow, the justice minister for Saxony. “But it unfortunately did.”