A file picture taken May 25, 2003, shows Iraq's largest refinery complex in the northern town of Baiji. Iraqi officials said pro-government forces broke Islamic State militants’ siege of the refinery on Nov. 15. (Karim Sahib/AFP/Getty Images)

Islamic State fighters began withdrawing from the area around the Baiji refinery in northern Iraq on Saturday, Iraqi officials said. The retreat would mark the end of the group’s month-long siege at a strategic oil installation and would be a significant victory for ­pro-government forces.

It remained unclear whether Iraqi forces passed through the gates of the refinery — Iraq’s largest — on Saturday afternoon. Iraqi security officials gave conflicting reports on whether police and army troops had entered the facility.

The operation to retake the terminal came as Gen. Martin Dempsey, chairman of the Joint Chiefs of Staff, arrived in the Iraqi capital on an unannounced visit.

Dempsey visited with U.S. troops, telling them that they had helped Iraqi forces “pull Iraq back from the precipice.”

“And now, I think it’s starting to turn. So well done,” Dempsey told a group of Marines at the U.S. Embassy in Baghdad, according to Reuters.

The U.S. government is set to increase the number of troops it will deploy to Iraq to advise and assist Iraqi forces in the fight against the Islamic State. The 1,500 additional troops will roughly double the size of the force the American government has dispatched since June.

According to Reuters, Dempsey said it was critical to show that the Islamic State was not an unstoppable, towering force but instead is “a bunch of midgets running around with a really radical ideology.”

But he also said defeating the Islamic State could not happen until the Iraqi government could bridge the differences between the nation’s Sunni and Shiite camps. He said this would require building trust, and like the U.S. mission, it could take “several years.”

Dempsey told Reuters that he also talked with top Iraqi officials on efforts to rebuild their forces, which had been overrun in northern Iraq during the summer by Islamic State forces, allowing the capture of strategic facilities, such as the Baiji refinery.

In June, Islamic State militants surrounded the refinery, about 110 miles north of Baghdad, trapping pro-government forces inside. But a contingent of Iraqi soldiers and government-aligned militia fighters held out against the militants, who staged repeated attacks to try to seize the terminal.

Police Brig. Gen. Khalil Ramal Ahmed said Saturday that as many as 400 members of the police force had arrived at the refinery from the south after the militants went into full retreat. But a spokesman for Asaib Ahl al-Haq, a government-aligned Shiite militia with forces inside the refinery, said that the siege had not yet been broken.

Pro-government forces “are very close, just a few meters away,” spokesman Naim al-Aboudi said Saturday afternoon. He said the militants had planted dozens of improvised explosive devices to slow the government advance.

“They have many wounded, and they are retreating,” he said of the Islamic State fighters. “But we are not inside yet.”

This past week, Iraqi forces staged a major offensive backed by U.S. airstrikes to retake the nearby town of Baiji from the militants, eventually seizing the area amid fierce fighting. Baiji is the largest town to be recaptured from Islamic State fighters since the group launched its stunning offensive across northern Iraq in June, overrunning major urban centers such as Mosul and Tikrit.

The Islamic State continues to make gains in western Iraq’s Anbar province, the heartland of a Sunni insurgency against U.S. and, later, Iraqi government forces in recent years.

But the government’s progress in Baiji is a serious blow to the militants in the north. Their blockade of the refinery had taken much of the country’s oil production off line, leading to reduced supplies for domestic consumption.

Mustafa Salim contributed to this report.