President Barack Obama said on Thursday he was sending up to 300 U.S. military advisers to Iraq but stressed the need for a political solution to the Iraqi crisis as government forces battled Sunni rebels for control of the country's biggest refinery.

Speaking after a meeting with his national security team, Obama said he was prepared to take "targeted" military action later if deemed necessary, thus delaying but still keeping open the prospect of airstrikes to fend off a militant insurgency. But he insisted that U.S. troops would not return to combat in Iraq.

Obama also delivered a stern message to Prime Minister Nuri al-Maliki on the need to take urgent steps to heal Iraq's sectarian rift, something U.S. officials say the Shi'ite leader has failed to do and which an al Qaeda splinter group leading the Sunni revolt has exploited.

"We do not have the ability to simply solve this problem by sending in tens of thousands of troops and committing the kinds of blood and treasure that has already been expended in Iraq," Obama told reporters. "Ultimately, this is something that is going to have to be solved by the Iraqis."

Obama, who withdrew U.S. troops from Iraq at the end of 2011, said the United States would increase support for Iraq's beleaguered security forces. But he stopped short of acceding to Baghdad's request for the immediate use of U.S. air power against Islamist insurgents who have overrun northern Iraq.

The contingent of up to 300 military advisers will be made up of special forces and will staff joint operations centers for intelligence sharing and planning, U.S. officials said.

Leading U.S. lawmakers have called for Maliki to step down, and Obama aides have also made clear their frustration with him. Some U.S. officials believe there is a need for new Iraqi leadership but are mindful that Washington may not have enough clout to influence the situation, a former senior administration official said.

While Obama did not join calls for Maliki to go, saying "it's not our job to choose Iraq's leaders," he avoided any expression of confidence in the embattled Iraqi prime minister when asked by a reporter whether he would do so.

Warning that Iraq's fate "hangs in the balance," Obama said: "Only leaders with an inclusive agenda are going to be able to truly bring the Iraqi people together."

The U.S. president also said he was sending Secretary of State John Kerry to Europe and the Middle East starting this weekend for talks he hoped would stabilize the region. A U.S. official said: "Kerry is expected to go Iraq soon," but did not give a date.

Obama's decision to deploy military advisers and deepen U.S. re-enagagement in Iraq came after days of arduous deliberations by a president who won the White House in 2008 on a pledge to disentangle the United States from the long, unpopular war there.

He said that recent days had reminded Americans of the "deep scars" from its Iraq experience, which started with the 2003 U.S.-led invasion that toppled Saddam Hussein and saw U.S. troops occupy the country for nine years.

Refinery becomes battleground

Even as Obama announced his most significant response to the Iraqi crisis, the sprawling Baiji refinery, 200 km (130 miles) north of the capital near Tikrit, was transformed into a battlefield.

Troops loyal to the Shi'ite-led government held off insurgents from the Islamic State of Iraq and the Levant, or ISIL, and its allies who had stormed the perimeter a day earlier, threatening national energy supplies.

A government spokesman said at one point on Thursday that Iraqi forces were in "complete control." But a witness in Baiji said fighting was continuing. Two Iraqi helicopters tried to land in the refinery but were unable to because of insurgent gunfire, and most of the refinery remained under rebel control.

A day after the government publicly appealed for U.S. air power, Obama's decision to hold off for now on such strikes underscored skepticism in Washington over whether they would be effective, given the risk of civilian deaths that could further enrage Iraq's once-dominant Sunni minority.

"We will be prepared to take targeted and precise military action if we conclude the situation on the ground requires it," Obama said. But he insisted that any U.S. military response would not be in support of one Iraqi sect over another.

Turkish Prime Minister Tayyip Erdogan, a NATO ally, said the United States "does not view such attacks positively," given the risk to civilians. A Saudi source said that Western powers agreed with Riyadh, the main Sunni state in the region, that what was needed was political change, not outside intervention, to heal sectarian division that has widened under Maliki.

Maliki's Shi'ite alliance won the most votes in April parliamentary elections, and U.S. officials said the Obama administration was pressing Iraqi authorities to accelerate the process of forging a new governing coalition and for it to be broad-based, including Sunnis and Kurds.

A senior member of Maliki’s State of Law list suggested immediate U.S. military action was no longer necessary because defenses in the capital, Baghdad, hade been strengthened and the new advisers would make it easier to bomb in the future if needed.

”Once they are down there, they will be able to do targeting,” the politician said, suggesting that Iraqi security forces have "bought time" by toughening their resistance to the insurgent advance.

But Obama's decision drew criticism from some Republican opponents.

Representative Edward Royce, who chairs the House Foreign Affairs committee, said "the steps he announced are needed but fall short of what is required to stop this al Qaeda offshoot from gaining more power, which must include drone strikes."

Video aired by Al-Arabiya television showed smoke billowing from the Baiji plant and the black flag used by ISIL flying from a building. Workers who had been inside the complex said Sunni militants seemed to hold most of the compound in early morning and security forces were concentrated around the control room.

The 250 to 300 remaining staff were evacuated early on Thursday, one of the workers said by telephone. Military helicopters had attacked militant positions overnight, he added.

Baiji, 40 km (25 miles) north of Saddam Hussein's home city of Tikrit, lies squarely in territory captured in the past week by an array of armed Sunni groups, spearheaded by ISIL, which is seeking a new Islamic caliphate in Iraq and Syria. On Tuesday, staff shut down the plant, which makes much of the fuel Iraqis in the north need for both transport and generating electricity.

ISIL's advance

ISIL, which considers Iraq's Shi'ite Muslim majority as heretics in league with neighboring Shi'ite Iran, has led a Sunni charge across northern Iraq after capturing the major city of Mosul last week as Maliki's U.S.-armed forces collapsed.

The group's advance has only been slowed by a regrouped military, Shi'ite militias and other volunteers. The government announced on Thursday that those who joined up to fight in "hot areas" would be paid about $150 a week.

ISIL, whose leader broke with al Qaeda after accusing the global jihadist movement of being too cautious, has now secured cities and territory in Iraq and Syria, in effect putting it well on the path to establishing its own well-armed enclave that Western countries fear could become a center for terrorism.

The U.S. secretary of state, Kerry, played down the extent of possible cooperation with Iran, the main Shi'ite power, which backs Maliki, saying Washington wanted communication on Iraq with its old enemy to avoid "mistakes" but would not work closely with Tehran.

Obama challenged Iran to play a constructive role in Iraq and not come in "solely as an armed force on behalf of the Shia."

Anthony Cordesman, an expert at the Center for Strategic and International Studies think tank in Washington, said Obama's decision guaranteed that the United States, not just Iran, would have a presence on the ground during the Iraq crisis.

"It gives the United States the kind of direct contact with Iraqi forces that allows them to judge their strengths and weaknesses and act as a check on sectarian abuses," he wrote. "It keeps up the right kind of pressure on Maliki and any successor."

From Iran, which has pledged to intervene if necessary in Iraq to protect Shi'ite holy places, a tweet from an account linked to Supreme Leader Ayatollah Ali Khamenei noted that Western powers supported the mostly Sunni revolt against Syria's Iranian-backed leader. It called for Sunnis and Shi'ites to resist efforts by the militants and the West to divide Muslims.

A group of Islamist Sunni scholars led by the influential Qatar-based cleric Youssef al-Qaradawi called on Arab and Islamic states to protect Iraqi Sunnis, saying a "revolution" was "natural" because of the "great injustice" done to them.