Iraqi forces have regained territory from the Islamic State of Iraq and Syria (ISIS) north of Baghdad as a top Iraqi general claimed the city is safe from militants who threatened to march on the Iraqi capital.

A number of towns in Salahuddin Province, including Baiji -- home to Iraq’s largest oil refinery -- were back in control of Iraqi security forces, Gen. Qassim Atta told a news conference Saturday.

“The security in Baghdad is 100 percent stable, the majority of Salahuddin Province has been regained, the morale of the security forces is very high,” said Atta, an Iraqi military spokesman who formerly served as director of operations for Iraq’s national intelligence service, according to the New York Times.

Maj. Gen. Qassim al-Moussawi, spokesman for the Iraqi military’s commander in chief, said volunteers who took up arms against ISIS contributed to the progress made against the Sunni militant group.

"Our security forces have regained the initiative to launch qualitative operations on various fronts over the past three days and have achieved remarkable victories with the help of volunteers," he said, according to Reuters. "We have regained the initiative and will not stop at liberating Mosul from [ISIS] terrorists, but all other parts.”

ISIS militants overtook Mosul, Iraq’s second-largest city, earlier in the week and pushed closer to Baghdad as it seized towns closer to the capital. But Atta said the Iraqi army reclaimed several towns along a highway that connects Iraq’s two biggest cities and is also making progress in Mosul, where he said “we have security forces functional and working there.” He also said that Samarra, home to the revered al-Askari shrine, has been secured. Militants attempted to take control of the city twice in recent days and threatened to destroy the shrine, a sacred site in Shiite Islam.

Atta downplayed media reports that the Iraqi army was being overwhelmed by ISIS forces.

“Don’t count on what the media are saying,” he said. “It’s not correct or accurate. We have distinguished operations underway and we will announce details after they’ve finished, after we start a new battle in Salahuddin, in Diyala, in Nineveh and Kirkuk."

The gains made by Iraqi security forces may have come with an assist from Iran. Iran has sent more than 2,000 troops to Iraq in the last two days in addition to two units of the elite Quds Force that were deployed Thursday to help the Iraqis defend Baghdad.

An Iraqi official told the Guardian on Saturday that 1,500 Iranian troops were deployed to Khanaqin in central Iraq late Friday and another 500 went to Wasat Province in the eastern part of the country, according to the Guardian. The deployments were preceded by about 150 forces from the elite Quds Force of the Iranian Revolutionary Guard.

Age-old enemies, Iran and Iraq have grown closer since Iraqi Prime Minister Nouri al-Maliki took power. Shiites are a majority in Iran while Maliki’s government is dominated by Shiites. Iraq is battling the al Qaeda offshoot ISIS, a Sunni Islam militant group.

Tehran may also be on the side of another longtime adversary, the United States, as President Barack Obama considers whether to take military action against ISIS. Obama said Friday he ruled out putting troops on the ground in Iraq, but may order an alternative use of force.

Iranian President Hassan Rouhani told a press conference that he was open to the idea of working with the Americans in Iraq.

"We can think about it if we see America starts confronting the terrorist groups in Iraq or elsewhere,” he said, according to Reuters. "We all should practically and verbally confront terrorist groups.”