TIKRIT, Iraq—When a cousin of provincial lawmaker Khazal Hammad tried to enlist last fall in one of Iraq’s Shiite militias, he was detained, questioned for hours and accused of belonging to the radical Sunni group Islamic State.

Since then, however, the young man and other Sunnis have fought alongside Shiite militias to recapture the city of Tikrit—the Iraqi security forces’ biggest victory over Islamic State since it seized large parts of the country last June.

Mr. Hammad and some other Sunni tribal leaders said the retaking of Tikrit last month, the first large-scale coordination between Iran-backed Shiite militias and Sunni tribal fighters, has helped to overcome their mutual suspicion.

While Iraq’s sectarian divisions remain formidable, Mr. Hammad’s experience in Tikrit offers an instance of collaboration among many that the Iraqi government is eager to replicate as its forces push to seize back other regions dominated by the country’s Sunni minority. Whether the government succeeds in fostering such cooperation widely will go a long way in determining whether it prevails over Islamic State.

“Some people in Anbar claim the militias are like Islamic State, but I think the opposite,” said Sheikh Taher al-Dolaimi, a Sunni tribal leader in the Sunni-majority western province of Anbar. “My men keep telling me how militias are good and how they aren’t sectarian at all—completely the opposite to what others claim.”