BAGHDAD — Thousands of troops and militiamen amassed in northern Iraq on Saturday in preparation for a major offensive against the Islamic State-held city of Tikrit, and what Iraqi officials and militia commanders said would be an essential step toward the larger prize of Mosul.

Large convoys of Shiite fighters carrying flags and blaring battle songs began arriving in the government-held city of Samarra, 40 miles south of Tikrit, residents said. Qassim Soleimani, the leader of Iran’s elite Quds Force, was also in the city to oversee the operation, according to local officials.

Retaking roads and towns in Salahuddin province, wedged between Baghdad and militant-held Mosul, is necessary to shore up supply lines north from the capital for any future battles there. An operation to retake Tikrit would mark a major test for Iraqi forces, which have yet to regain a major population center from the militants.

“It will be a very hard fight,” said Jassim al-Jabara, head of the security committee for the Salahuddin provincial council. The operation will begin “very soon,” he said. Sheik Jassim al-Saidi, a commander with Kitaeb Hezbollah, and other militia leaders said the offensive could take 10 days.

In January, Iraqi Prime Minister Haider al-Abadi told Reuters that a campaign to retake Tikrit would be launched within a month. He said then that there was no timeline for an attack on Mosul, which requires more planning. A U.S. Central Command official said on Thursday that an assault could begin in April or May, though military experts and Iraqi commanders have questioned whether the country’s ground forces would be ready.

The government is relying heavily on increasingly powerful Shiite militiamen for security, leaving the U.S.-led training program for regular forces struggling to catch up.

Iranian-backed militias confirmed that they had dispatched convoys of fighters to Samarra on Saturday, but they declined to give figures.

More than 10,000 militiamen have gathered and will attack from multiple fronts, according to Karim al-Nouri, spokesman and military commander for the Badr Organization, one of Iraq’s most prominent Shiite militias.