Displaced Iraqis cross the Bzebiz bridge as they make their way back home to Ramadi, the capital of Anbar province, on April 21, 2015. (Hadi Mizban/AP)

Thousands of police officers and residents who fled Ramadi after an Islamic State offensive last week have begun to return home after reinforcements were dispatched to shore up the center of the western city, Iraqi military officials said Wednesday.

About 5,000 local police officers, nearly the entire force, had left their positions as fear engulfed the capital of Anbar province last week, according to Staff Maj. Gen. Mohammed Khalaf Saeed, acting head of Anbar Operations Command. At the height of the panic, just 1,000 security forces, including army and counterterrorism troops, were left to protect multiple front lines, he said.

The Islamic State’s push into several neighborhoods on the outskirts of Ramadi sparked a civilian exodus, with about 90,000 people fleeing, according to the United Nations. The militant group’s advance came despite seven months of U.S.-led airstrikes in the area.

With local police forces now returning and reinforcements arriving, officials said the security situation has improved but warned that it remains precarious. Although some families that fled have been able to return to areas in the heart of the city, other neighborhoods remain under ­Islamic State control or are engulfed by fighting.

“We still need more forces,” Saeed said, even as he acknowledged gains made in recent days. “Before, it was a real crisis. Thank God we were able to withstand.”

Four regiments of federal police and counterterrorism forces have arrived in recent days, and traffic is now moving in both directions on the footbridge that represents the main crossing point between the province and Baghdad. Last week, the crossing was jammed with fleeing families.

“The situation has now stabilized,” said Muhannad Haimour, a spokesman for Anbar’s governor. “Some families are heading back, and hardly any are leaving.”

Tough conditions in Baghdad, where displaced families from the largely Sunni province are viewed with suspicion and require a sponsor to gain entry, mean that many are desperate to return home, he said. Both Sunni and Shiite mosques have opened their doors to help with the influx, but assistance remains limited at a time when Iraq is struggling with about 2.7 million internally displaced people.

About 2,500 Ramadi police officers have returned to duty after escorting their families to safety, Saeed said. Most had been desperate to get their families out, he said.

“Some police stations were completely empty,” said Abdullah Zebar al-Alwani, a tribal fighter in the city. “Now the officers are starting to come back, but counterterrorism are the only forces doing a good job here.”

Zamil Adnad, a 28-year-old police officer, said he had returned to the police station in Ramadi’s ­al-Hoz district on Wednesday with 15 of his colleagues after fleeing earlier in the week. He left his family in the capital.

“I was being humiliated in Baghdad,” he said, complaining about the sponsor system. “I’d rather die here than go back there.”

The system requires a Baghdad resident to travel to the border of the province to vouch for an entering family. But families from ­Anbar also receive extra scrutiny at checkpoints, he said, because they are considered security risks.

Since the return of local police personnel, he said, a maternity hospital in al-Hoz has been recaptured from militants. Other small advances have been reported in eastern Ramadi.

Nonetheless, “the situation is still dangerous,” said Maj. Omar Khamis al-Dahl, a police officer in the city. “There’s a bad situation in central Ramadi, and we can’t move forward because of roadside bombs and snipers. We don’t receive any support from the army, and the reinforcements are not enough.”

Saeed agreed that more reinforcements are needed, calling the current deployment of 1,200 soldiers in the area insufficient.

With the city teetering, the Iraqi government has been weighing whether to dispatch popular mobilization forces, which include Shiite militias.

“If the central government can’t send any reinforcements from the army, then we will need the public mobilization units,” Saeed said.

Some Sunni tribal leaders have pushed back against the involvement of the militias, though tribal fighters on the ground say any help would be welcome. U.S. officials have stressed that tribal fighters from the area need to play a key role, but Sunni tribes say they are hampered because the central government has given little assistance.

Alwani, however, blamed Sunni tribal leaders.

“They are all thieves,” he said. “They take all the money and weapons, and the real fighters who are on the ground get nothing.”

Mustafa Salim contributed to this report.

Read more:

The Islamic State was dumped by al-Qaeda last year. Now look at it.

Petraeus: The Islamic State isn’t our biggest problem in Iraq

Shiite militias backed by Iran could undermine U.S., Iraqi strategy