An oil refinery is seen in the city of Beiji, home to Iraq's largest oil refinery, in 2003. / AP

by Kim Hjelmgaard and John Bacon, USA TODAY

by Kim Hjelmgaard and John Bacon, USA TODAY

Iraq's army claimed Wednesday it had repelled an attack on the nation's largest oil refinery and killed 40 militants while the nation's prime minister provided an upbeat assessment on government gains in a nationally televised address to the war-weary nation.

Chief military spokesman Lt. Gen. Qassim al-Moussawi announced that government forces had retaken control of the Beiji refinery shortly after Reuters, citing unnamed security sources and refinery employees, reported that the refinery may largely be controlled by insurgents.

"The militants have managed to break in to the refinery. Now they are in control of the production units, administration building and four watch towers. This is 75% of the refinery," an official speaking from inside the refinery had told Reuters. It was not clear why the official spoke on the condition of anonymity.

Prime Minister Nouri al-Maliki, however, assured the nation that his government has regained the initiative after the "shock" defeat of army and security forces in the country's north.

"We were able to contain the strike and arrest deterioration. â?¦ We have now started our counteroffensive, regaining the initiative and striking back," al-Maliki said.

Al-Maliki, a Shiite, has requested U.S. airstrikes to blunt the momentum of the Sunni uprising in the Shiite-majority country. President Obama has demurred, instead pressing the prime minister to work with the Sunni population to drain the energy from the militant push. The Obama administration also has made overtures to Shiite-majority Iran, which would see no political gain from the fall of the Iraqi government.

Control of the nation's oil facilities are key to maintaining control of the country. On Tuesday, the Beiji refinery was shut down and foreign workers were evacuated as Iraq security forces prepared for a raid of the compound by insurgents. The sprawling facility is situated about 50 miles north of Tikrit.

The Beiji refinery accounts for a little more than a quarter of the country's domestic refining capacity. Any lengthy outage at Beiji risks long lines at the gas pump and electricity shortages.

Crude oil prices edged higher on the news of the attack, which is taking place with mortars and machine guns. The July crude oil futures contract added 29 cents to the barrel early Wednesday, pushing the price to $106.65.

Other clashes between Sunni Muslim militants from the al-Qaeda breakaway group known as the Islamic State of Iraq and the Levant - referred to as ISIL or ISIS - and security forces continued Wednesday in areas to the north of Iraq's capital Baghdad.

But if the Beiji refinery were to fall it could prove to be a dramatic new twist in the story and may have a big impact on supplies in Iraq and potentially across the world. Iraq is a major supplier of the world's oil.

"An increasing risk of supply outages in Iraq comes against a backdrop of an already tight global demand/supply balance that has markets already on edge," IHS energy experts wrote in a recent note.

Meanwhile, the Turkish Foreign Ministry said its diplomats were investigating claims that militants abducted 60 foreign construction workers, including some 15 Turks, near the oil city of Kirkuk in northern Iraq.

Separately, speaking live on television on Wednesday, Iranian President Hassan Rouhani said his country stood ready to defend Shiite Muslim holy sites in neighboring Iraq against "killers and terrorists," according to Reuters.

"We declare to all superpowers, their mercenaries, murderers and terrorists that the great Iranian nation will not miss any effort in protecting these sacred sites," Rouhani said.

Washington has yet to decide how it will deepen its involvement in the conflict although it has deployed a few hundred troops to protect the U.S. Embassy in Baghdad and other American interests.