* Baiji refinery attacked, four people killed
* Damage severe, will take days to fix
* Small Samawa refinery also shut after fire
(Adds second refinery shutdown, paragraphs 2, 13-14)
By Sabah al-Bazee
BAIJI, Iraq, Feb 26 (Reuters) - Militants attacked Iraq's largest oil refinery on Saturday, killing four workers and detonating bombs that touched off a raging fire and shut down the plant in northern Iraq, officials said.
In the southern town of Samawa, a second refinery was shut down by fire but officials said initial reports indicated it was started by a technical failure rather than an insurgent attack.
The militants planted explosives at a kerosene and benzene production unit at the northern refinery in the town of Baiji, a former al Qaeda stronghold 180 km (112 miles) north of Baghdad, the governor of Salahuddin province, Ahmed al-Jubouri, said.
"The refinery has completely stopped," Jubouri told Reuters. "It's a big loss for the whole country. All Iraqi cities depend on its production."
Oil Minister Abdul-Kareem Luaibi said the "terrorist attack" hit only one production unit, which was under maintenance, and the remaining units have not been damaged.
"The attack is part of a terrorist plan, which targets Iraq's oil facilities and aims to undermine the Oil Ministry after it succeeded in supplying enough oil products to meet domestic needs," he said in a statement read to Reuters.
The blast, which happened before dawn, sparked a fire that was later brought under control, a police source said. It took about five hours and up to 50 fire trucks to contain the blaze.
The damaged unit, known as the North Refinery, has a production capacity of 150,000 barrels per day, a Baiji official said, adding the damage has been too severe to fix in few days.
"Fixing the damage will take long time. We are not talking about days, the damage is too severe," said the Baiji official, who asked not to be named.
"Hopefully in the next few days we can partially restart the refinery," he said, adding that the plant has enough stock to cover domestic needs for at least seven days.
Iraq does not export any oil products as it uses all of its production for power generation and domestic consumption.
The country's capacity to refine fuels like diesel and gasoline has been ravaged by under-investment, and it has been forced since the 2003 U.S.-led invasion to buy imported fuels to meet the growing gap between supply and domestic demand.
The Samawa refinery, a 30,000 barrel-per-day facility was shut down when fire broke out in one of its main storage areas on Saturday, officials said.
"The refinery was shut down after the fire as a preemptive measure and it's expected to restart in two to three days," a source at the refinery told Reuters.
Baghdad has signed multi-billion deals with international oil companies to boost output capacity to 12 million barrels a day in seven years, rivalling top oil exporter Saudi Arabia.
But everything depends on whether the OPEC member can secure its vital oilfields, refineries and other infrastructure against insurgents and militia.
Overall violence in Iraq has dropped sharply since the peak of sectarian conflict in 2006-07 but attacks still occur daily.
Several years ago al Qaeda had enough control over the Baiji area that it was able to intimidate refinery workers and hijack its refined products. It sold the products to neighbouring countries and used the profits to finance the insurgency.
Baiji, which normally operates at about 70 percent of its 310,000 bpd capacity, and produces 11 million litres of gasoline, 7 million litres of benzene and 4.5 million litres of kerosene a day. The refinery was last shut in August for two days due to an electrical fault.
Iraq has eight oil refineries with a capacity of 659,000 bpd. It produces about 453,000 bpd of refined products and uses 589,000 bpd, according to the OPEC website. (Additional reporting by Ahmed Rasheed in Baghdad and Aref Mohammed in Basra; writing by Rania El Gamal and Jim Loney)