WASHINGTON — Inching back into a fight he tried to leave behind, President Barack Obama announced Thursday he was dispatching 300 U.S. military advisers to Iraq to help quell the rising insurgency in the crumbling nation. He also challenged Iraq’s embattled leader to create a more inclusive government or risk his country descending into sectarian civil war.
‘‘The test is before him and other Iraqi leaders as we speak,’’ Obama said of Iraqi Prime Minister Nouri al-Maliki, whose political fate appeared increasingly in play as his rivals launched a secretive effort to replace him.
Less than three years after Obama heralded the end of America’s war in Iraq, he insisted he was not sending the military back into combat. Still, when coupled with previously announced steps, the president’s actions could put about 600 additional U.S. troops in the midst of Iraq’s deeply unstable security situation.
Underscoring the volatility was a tenacious fight over Iraq’s largest oil refinery north of Baghdad. Iraqi soldiers and helicopter gunships battled Sunni militants for a third day on Thursday for control of the refinery, the loss of which would be a devastating symbol of the government’s powerlessness in the face of a determined insurgency hostile to the West.
Despite the deteriorating conditions, Obama held off approving airstrikes that the Iraqi government has sought to stem an insurgency that has taken over the cities of Mosul and Tikrit and has pressed toward Baghdad. The president said he could still approve ‘‘targeted and precise’’ strikes if the situation on the ground required it, noting that the U.S. had stepped up intelligence gathering in Iraq to help identify potential targets.
Officials said manned and unmanned U.S. aircraft are now flying over Iraq 24 hours a day on intelligence collection missions. If the U.S. were to proceed with airstrikes, officials did not rule out the prospect of hitting targets in Syria, where the militant group pressing through Iraq also has deep ties.
Even as Obama left the door open for a direct military response, he said Iraq’s future ultimately rests with its leaders’ willingness to embrace a more inclusive political system. Al-Maliki has long faced criticism from the U.S. for not giving Iraq’s Sunni minority a greater role in the Shiite-dominated government. Secretary of State John Kerry is expected to travel to Iraq soon to press its government to share more power.
While U.S. officials have increasingly raised questions privately about whether al-Maliki can lead his country out of the current crisis, Obama stopped short of calling for the prime minister to step down, saying ‘‘it’s not our job to choose Iraq’s leaders.’’
But in what appeared to be a pointed warning to al-Maliki, Obama said: ‘‘Only leaders that can govern with an inclusive agenda are going to be able to truly bring the Iraqi people together and help them through this crisis.’’
A leading Sunni tribal chief said Washington’s decision to send the military advisers would only make the fighting worse. Sheik Ali Hatem al-Suleiman, whose men are involved in the Sunni insurgency led by the al-Qaida inspired Islamic State of Iraq and the Levant, said the violence would end only if al-Maliki stepped down.
Both al-Maliki’s Sunni opponents and many of his former Kurdish and Shiite allies have been clamoring to deny the prime minister a third term in office, saying he has excluded them from a narrow decision-making circle. Iraqi political leaders and U.S. officials also have met in recent days to discuss al-Maliki’s future.
Possible candidates were already lining up to replace al-Maliki, according to Shiite politicians familiar with the secretive efforts. Among them are former vice president Adel Abdul-Mahdi, a French-educated economist who is also a Shiite; and Ayad Allawi, a secular Shiite who served as Iraq’s first prime minister after Saddam’s ouster.
Also lobbying for the job is Ahmad Chalabi, a Shiite lawmaker who recently joined the Supreme Council and was a favorite by Washington to lead Iraq a decade ago.
The jockeying has been prompted by the lighting gains of the ISIL, an insurgency fueled in part by the civil war in neighboring Syria. The militants have sparked a fresh cycle of sectarian violence in Iraq, which continued Thursday when the bullet-riddled bodies of four handcuffed men, presumably Sunnis, were found in a Shiite neighborhood of Baghdad.
The fight continued for control of the Beiji oil refinery, with Iraq’s government desperately seeking to hold off the extremists. By late Thursday, the two sides held different parts of the refinery, which extends over several square kilometers of desert.
The 300 Green Beret special operations forces Obama plans to deploy to Iraq will be focused on assessing the state of the Iraqi security forces, which have struggled to hold off the insurgent advances and in some cases have deserted their units. Initially the deployments will be limited to several teams of about a dozen soldiers apiece who will operate mainly in Baghdad at various Iraqi military headquarters.
The first wave will also assess the state of the battle with the insurgents and set the stage for the deployment of follow-on military adviser teams. More broadly, the role of the advisers is to gather intelligence and share it with the Iraqi forces, and assess how best to increase the training and equipping of Iraqi Security Forces in their fight with the insurgents.
The military advisers will join up to 275 U.S. forces that Obama previously announced would be positioned in and around Iraq to provide security and support for the U.S. Embassy in Baghdad and other American interests.
Mindful of what he called ‘‘the deep scars left by America’s war in Iraq,’’ Obama was adamant that U.S. troops would not be returning to combat.
‘‘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 declared at the White House. ‘‘Ultimately, this is something that is going to have to be solved by Iraqis.’’
On Capitol Hill, congressional reaction to Obama’s decisions broke down along party lines with Republicans criticizing him but offering wildly different recommendations of what steps to take. Democrats cautiously backed the president.
Rep. Ed Royce, R-Calif., chairman of the House Foreign Affairs Committee, pushed for airstrikes. Rep. Howard ‘‘Buck’’ McKeon, R-Calif., chairman of the Armed Services Committee, complained that Obama’s ‘‘half-step’’ wouldn’t resolve the crisis. McKeon pressed for a comprehensive course of action but provided no specifics on what that should be.
Democratic Sen. Tim Kaine of Virginia and Independent Angus King of Maine welcomed the limited U.S. military support to the Iraqi forces. House Democratic leader Nancy Pelosi, speaking in advance of the president’s announcement, voiced concern about dispatching even a small contingent of Americans to Iraq.
‘‘I think that you have to be careful sending special forces because that’s a number that has a tendency to grow,’’ she said.
Hendawi reported from Baghdad. Associated Press writers Diaa Hadid in Iraq and Lara Jakes, Matthew Lee, Robert Burns, Lolita C. Baldor and Donna Cassata in Washington contributed to this report.