BEIRUT—Iraqi Shiite militias that have provided crucial support to President Bashar al-Assad on Syria's battlefields are remobilizing to Iraq to help the government there fight off opposition forces closing in on Baghdad, diplomats and Syrian rebels say.

The mobilization away from Syria started in late December when antigovernment forces seized Iraq's western Anbar province, but has recently gained pace as militants have taken more territory, including Mosul, Iraq's second-largest city. Fighters from Hezbollah are filling the vacuum left in Syria by the withdrawing Iraqi militias, according to Syrian rebels and an official close to the Lebanese militant and political group.

Many of these Shiite militants are leaving Syria to fight alongside the Iraqi army, say Western and Arab diplomats, increasing the sectarian undertone of the conflict. The militants' mobilization underscores accusations from Iraqi Sunnis that the Shiite-led government in Baghdad is dragging state institutions into a bloody sectarian war.

Iraqi Prime Minister Nouri al-Maliki and Grand Ayatollah Ali al-Sistani, the country's most influential Shiite cleric, set off a massive mobilization effort last week when they called for all able-bodied men to fight off antigovernment forces. The opposition forces include the Islamic State of Iraq and al-Sham, a renegade offshoot of al Qaeda, and more moderate Sunni tribal leaders who have long accused Mr. Maliki of oppressing Iraq's Sunni minority.

"The Iraqi Shiite militias are being pulled out from Syria to Iraq," said an Arab diplomat focused on the conflict, adding that the move will worsen the conflict. "We've reached this point in Iraq because of the sectarianism of Maliki. ISIS didn't capture these [Iraqi] cities with a few thousand fighters without Maliki providing the breeding ground for this situation."