BAGHDAD – Under heavy pressure from the United States, Iraqi lawmakers took a significant step Monday by choosing a replacement for Prime Minister Nouri al-Maliki, who is widely blamed for their country’s polarized politics.

However, al-Maliki angrily rejected the move, vowing to fight in the courts and perhaps by use of force, throwing the country into new uncertainty even as it fights an onslaught by Sunni militants.

The change in leadership could help soothe Iraq’s sectarian fractures and unite the country under al-Maliki’s nominated successor, a member of his own Shiite party. But al-Maliki’s insistence that he is the rightful leader could just as easily tear Iraq further apart.

Further complicating the picture was the United States, which helped orchestrate al-Maliki’s rise to power eight years ago but now holds him responsible for alienating the country’s Sunni minority and helping fuel the rise of the Islamic State, the Sunni extremist group. Territorial gains by the Islamic State in the north prompted a new military intervention by the United States – and gave the U.S. fresh leverage to demand political changes in Baghdad.

The showdown came as the United States increased its role in fighting back Sunni extremists of the Islamic State group that is threatening the autonomous Kurdish region in the north. Senior American officials said U.S. intelligence agencies are directly arming the Kurds who are battling the militants in what would be a shift in Washington’s policy of only working through the central government in Baghdad.

President Obama welcomed the nomination of a new prime minister, Haider al-Abadi, interrupting his vacation on Martha’s Vineyard, Mass., to announce in a televised statement that both he and Vice President Biden had congratulated al-Abadi on the phone, calling his nomination “an important step towards forming a new government that can unite Iraq’s different communities.”

But Obama also reminded the Iraqis that America’s renewed military assistance – punctuated by the airstrikes that began pounding Islamic State positions last week – was no solution to what he called the larger crisis in Iraq. “The only lasting solution is for Iraqis to come together and form an inclusive government,” he said.

Although al-Maliki is widely reviled in Iraq, he remains a formidable force, with relatives who command special security forces, courts that are heavily shaped by his influence and a history of exacting revenge on his domestic opponents. Al-Maliki’s stubbornness presents multiple challenges to the United States, which wants to preserve Iraq’s cohesion while helping to stop the Islamic State’s avowed goal of creating a monolithic Islamic caliphate that ignores national boundaries.

Obama spoke after a day of high political drama in Baghdad, where al-Maliki appeared on state television and blamed the United States for “standing beside those who violated the Iraqi Constitution.” The stage was set for more drama in the coming days, as the new nominee works to form a government, and al-Maliki pursues his bid to remain in power through a legal challenge, or as some worry, the use of the military to guarantee his survival.

“We will fix the mistake,” he said, without being specific.

The nomination of al-Abadi came hours after a television appearance Sunday, just before midnight, by a defiant al-Maliki, who had already deployed extra security forces around the capital. In that speech he challenged the Iraqi president, Fouad Massoum, and threatened legal action against Massoum – and implied that the army was ready to step in and defend the constitution – for not choosing him.

In Washington, the Sunday routines of officials who work on Iraq policy were suddenly interrupted. U.S. officials, worried that a coup might be underway, scrambled to ensure that al-Maliki’s rivals would decide on an alternative candidate by Monday. They sent a pointed message to al-Maliki not to target political rivals for arrest, as he has done many times in the past, according to a senior Shiite lawmaker involved in the government formation negotiations.

A senior State Department official said that al-Maliki appeared to be mounting a “last, desperate effort to try to force some kind of a deal.” The official added, “He ain’t going to be prime minister.”

Other senior Obama administration officials said U.S. representatives in Iraq had been increasingly and deeply involved in Baghdad discussions during the last 10 days to settle on an alternative to al-Maliki.

The officials said they were in constant contact with the new Iraqi president over the last several weeks as Massoum sought to narrow the possible candidates from five to one. Sunday, as the deadline approached, U.S. officials were in conversations throughout the day, urging the various factions to coalesce around a nominee, officials said.

The message, according to one senior administration official: Your country is in desperate straits and you need to get together and make some political decisions.

On television Monday afternoon, as Baghdad wondered if a coup was imminent, competing visions played out – one of the country uniting, the other spiraling further apart. In midafternoon, in a show of national unity, the new president, a Kurd, and the new speaker, a Sunni, stood with several Shiite lawmakers to formally nominate al-Abadi.

“The country is in your hands,” Massoum said to al-Abadi.

With a smile, another Shiite lawmaker then shook al-Abadi’s hand and said, “May God help you.”

Hours later, al-Maliki appeared on television next to an ever shrinking circle of Shiite allies from his party. He did not speak then – although he would later in the appearance in which he castigated the U.S. – but a surrogate, Khalaf Abdul Samad, id.

“Abadi does not represent the Dawa Party; he represents himself only,” Samad said. “We are sticking with Maliki as our only candidate for prime minister.”

Samad said that al-Maliki would pursue a legal challenge against Massoum’s choice of al-Abadi, arguing that it was al-Maliki’s bloc, State of Law, that has the constitutional right to have the first opportunity to form a new government.

The question now is whether al-Abadi, who like many of Iraq’s Shiite leaders led a life of exile until the U.S. invasion in 2003 ousted dictator Saddam Hussein, can forge a grand political bargain with meaningful roles for the two significant minority factions, Sunni Arabs and Kurds. Under the constitution, he has a 30-day window to conclude the sort of backroom deals – promises of positions and ministries, which sustain Iraq’s system of patronage – that would be the backbone of a new government.

Most Iraqi leaders, by now so exasperated by al-Maliki’s leadership and his insistence on clinging to power, have said that any other Shiite lawmaker will do.

“Really, at this point, I think it’s anybody but Maliki,” said a Kurdish politician who asked not to be identified because of the sensitivity of the situation.

For weeks, under pressure from both the Americans and Iraq’s Shiite religious leaders, lawmakers met to negotiate over the prime minister position. Several names were discussed, including Ahmed Chalabi, the former exile who fed intelligence, now debunked, about Hussein’s weapons programs to U.S. intelligence agencies that were used to justify the invasion.

It was only during the last week that al-Abadi became a candidate. He is a onetime ally of al-Maliki’s, and because al-Abadi is from the same party his candidacy became attractive, as it recognized the legitimacy of the election victory for al-Maliki’s bloc in April’s national elections.