BAGHDAD — Iraqi troops clashed with Islamic State militants in the northern city of Tikrit on Friday, as pro-government forces tightened their grip on the extremist stronghold, officials said. But tensions flared between security forces and locals in the area, adding to fears of intensified strains in this deeply polarized country.

Pro-government troops — the bulk of whom are Iranian-backed Shiite paramilitaries — took over most of Tikrit this week following a mammoth offensive, officials said. The assault marked the first major push by largely Shiite forces into Iraq’s Sunni heartland, where the jihadists had seized large areas. The fall of Tikrit is a substantial blow to the extremists, whose raison d’etre is capturing land to build an Islamic caliphate.

Officials said Friday that the battle in Tikrit would likely extend into next week, as security forces searched for militants and dismantled improvised explosives planted by the jihadists. Security officials had set no time frame for the return of civilians to Tikrit or surrounding areas, even where Shiite militias were firmly in control, officials said. Already there were reports of arbitrary arrests of residents who had not fled the fighting.

How Iraqi forces handle the aftermath of the battle is key to bridging Iraq’s sectarian divide. The rift between the Shiite-led government and minority Sunni communities contributed to the Islamic State’s rise. The group captured Tikrit in June.

Government forces said they were securing towns around Tikrit to ensure residences had been cleared of explosives and Islamic State snipers. In Alam, north of Tikrit, pro-government Sunni fighters from a local tribe are now patrolling the streets, enabling residents to return after nine months of Islamic State rule.

But in other districts, where residents are suspected of collaborating with the jihadists, Shiite militias were managing security — and civilians displaced by the violence have not returned, officials say.

About 260,000 people lived in Tikrit before the Islamic State took control. Most of the civilian population fled when the Sunni extremists moved in.

Militia leaders and government officials said they uncovered a mass grave outside the village of Abu Ajeel, east of Tikrit. Officials said forensic experts would be deployed to determine if the bodies were victims of the massacre of as many as 1,700 soldiers by the jihadists in June. Officials said they did not know how many corpses had been found.

The Islamic State’s loss of Tikrit comes as the group — also known as ISIS or ISIL — is already suffering from defections and internal divisions.

The Islamic State’s aura “is being pierced because we see that they are having setbacks, that there is some dissension in the ranks,” CIA Director John Brennan said in a speech in New York on Friday. “We are seeing right now some very significant indicators that ISIL’s engine is suffering.”

However, he added: “That doesn’t mean it is out of steam.”

Indeed, a key test of the Tikrit battle will occur in coming days, as residents return home — or don’t. Some areas in Iraq that have been retaken from the Sunni extremists have remained virtual ghost towns, with Sunnis afraid they will be targeted as Islamic State collaborators if they come back. In other places, militias that have driven out the Sunni jihadists have carried out abuses against Sunni residents.

Residents of Dawr, south of Tikrit,said they were fearful about reprisal attacks. Some residents had fled, but others had stayed behind and lived under Islamic State rule. A powerful Shiite militia, Kataib Hezbollah, is now in control.

“No one has even mentioned when [residents] will be able to go back,” said Mustafa al-Douri, a resident of Dawr.

Sunni parliamentarians and local tribesmen said Friday that Shiite militiamen had arrested a local sheik, Thaman al-Douri, and at least 12 relatives. Members of the largely Shiite Hashd al-Shaabi — or popular mobilization forces recruited to supplement the military — arrested Sheik Thaman and took him from his farm on the outskirts of Dawr, his relatives said.

The Islamic State had also targeted Thaman, who did not support the group, his relatives said. When the militiamen arrived at Dawr about a week ago, he welcomed them, they said.

But then the gunmen asked for his phone, which had been stolen by the jihadists, said the sheik’s brother, Maqsud al-Douri.

“They hit him and insulted him, and they took him and the people with him to an unknown place,” said Maqsud al-Douri, who is also the head of Dawr’s local provincial council.

As many as 27 residents of Dawr were detained, according to local officials. When the tribesmen called one of their relatives who had been arrested, a stranger answered the phone and told them not to ask about the detainees again, they said.

“We are being burned by two fires,” said Sheik Khaled Shehab al-Douri, another of Sheik Thaman’s brothers, who fled Dawr in June. “The fire of the Islamic State that blew up our houses and arrested our sons. And now the fire that is coming from the popular mobilization forces who have also taken our people. Which side should we choose?”

The Dawr area was a regime stronghold under former Iraqi ruler Saddam Hussein, who was captured hiding in the town in December 2003, months after he was toppled in the U.S.-led invasion. Many of his former lieutenants later joined the Islamic State. Forces supporting the current government suspect anyone with ties to Saddam’s rule of cooperating with the jihadists, said Aymenn al-Tamimi, of the Philadelphia-based Middle East Forum.

Officials on the provincial council in Salahuddin, where Tikrit and Dawr are located, said the militia forces had arrested residents and damaged property in Sunni areas.

The security forces “have randomly arrested people, and we don’t know their fate,” said the deputy head of the provincial council, Jassim al-Atiya. “This will have a negative effect” on efforts to persuade locals to support the government, he said.

The head of the provincial council, Ahmed al-Karim, also said some residents had been arrested by security forces. “Their interrogation is ongoing,” he said, and they are being detained in the city of Samarra. “But I don’t know how many there are.”