Saadiya and Jalawla, less than 20 miles from the Iranian border, were retaken after a two-day operation that brought together Iraqi army and police units along with Shiite paramilitary groups and Kurdish peshmerga fighters, officials said.
A statement from the Interior Ministry said the towns had been liberated "from the defiling of the terrorist gangs of Daesh," an Arabic term for Islamic State.
Vast stretches of Iraqi territory still remain under the sway of Islamic State, including much of Anbar province in the west; the northern city of Mosul, Iraq’s second-most populous city; and other areas. Retaking those will be a much greater challenge.
The Badr Organization, a powerful Iraqi Shiite militia backed by Iran, was a major participant in the operation to retake Saadiya and Jalawla. According to the group's Facebook page, its leader, Iraqi Transportation Minister Hadi Amiri, led the militiamen in the attack.
More than 70 Islamic State militants were killed and survivors fled to the nearby Hamrin Mountains, said Jabar Yawar, secretary-general of the Ministry of Peshmerga, who was reached by phone in the northern city of Irbil.
"Today there are operations to comb those areas,” said Yawar, referring to the mountains.
Diyala, an embattled, ethnically mixed province, was an important stronghold for Al Qaeda-affiliated militants during the U.S.-led occupation of Iraq from 2003 to 2011. Parts of the province remain under the sway of Islamic State.
The towns of Saadiya and Jalawla were overrun by Islamic State in August, part of a militant blitz through stretches of Iraq that left Iraqi and peshmerga forces reeling. Iraqi commanders say they have since regrouped and made gains against the militants, aided by U.S. airstrikes.
The militant threat to Iraq prompted a U.S.-led coalition to initiate a widescale aerial campaign to "degrade and ultimately destroy" Islamic State, in the words of President Obama.
On Monday, U.S. Central Command issued a statement saying allied aircraft had conducted 15 more strikes in Iraq and nine in Syria against Islamic State targets.
However, coalition aircraft did not participate in the battle for Saadiya and Jalawla, Iraqi officials said. Instead, "intense bombing" was undertaken by Iraqi warplanes and helicopters, according to Yawar, the peshmerga official.
Pro-government forces had been poised to take the town since September, officials said, but their advance was hampered by the large number of improvised bombs that have become the calling card of retreating Islamic State militants. Many explosive devices remain in the area, officials said.
Peshmerga forces have declared Jalawla a military zone for 14 days while work is completed "to remove tens of explosive canisters and mines and dealing with booby-trapped homes,” reported Sumariya News, an Iraqi media outlet.
Bulos is a special correspondent. Times staff writer Patrick J. McDonnell contributed to this report.