Iraqi soldiers surrounded and took control of the country's biggest oil refinery Saturday, which has been besieged for days by Islamic State militants, a senior official said.

The refinery at Beiji, north of Baghdad, has been held by the Iraqi military for months despite the militants' onslaught. However, ISIS militants recently carried out a major attack and took over a small part of the complex. Retaining control remains crucial for the country, as it accounts for a little more than a quarter of the country's entire refining capacity.

Abdel-Wahab al-Saadi, the top military commander in Iraq's Salahuddin province, said ground forces entered the refinery Saturday.

"It is another victory achieved by Iraqi security forces that are growing confident in the war against the terrorists," al-Saadi told The Associated Press.

The victory comes as Iraqi government forces and allied Shiite and Sunni fighters-- backed by airstrikes from the U.S.-led international coalition—have been locked in intense battles with ISIS militants to retake key cities and territory in northern and western Iraq.

A day earlier, Iraqi soldiers, backed by U.S.-led coalition airstrikes and Shiite and Sunni, gained control of the towns of al-Malha and al-Mazraah, located 1.9 miles south of the refinery.

Special forces also managed to maintain control of the provincial capital, Ramadi, in Iraq’s western province Friday, despite ISIS forces pounding the city with bombings and forcing residents to flee.

Anbar provincial council member Athal al-Fahdawi had said Thursday that the city was "in great danger," the BBC reported. Nine people were killed by militants in the village of Albu Ghanim— four of the victims were police officers, the Kurdish website Rudaw said- and thousands of people fled Ramadi and surrounding areas in recent days.

Suicide bombers had attacked government buildings and checkpoints in Ramadi earlier in the week and Friday a series of bombings ripped through Baghdad, mainly targeting public places and killing at least 40 people, Iraqi officials said.

On Saturday, Kurdish peshmerga forces recaptured two villages just south of the oil-rich city of Kirkuk that lie near the highway linking it to Baghdad, said Rasould Omar, a senior official in the Patriotic Union of Kurdistan.

Meanwhile, the Turkish Foreign Ministry said in a statement late Friday that two of the dead in the bombing near the U.S. Consulate in Irbil are believed to be Turks. The bombing killed three people. U.S. officials said there were no American casualties.

In separate violence Saturday, police said a bombing on a commercial street killed three persons and wounded 10 in central Baghdad. A roadside bomb missed a police patrol in the capital's western suburbs, killing one civilian and wounding three, officers said.

Police said a sticky bomb attached to a minibus also exploded in Baghdad's southeastern district of New Baghdad, killing three passengers and wounding seven.

The Associated Press contributed to this report.