Army Gen. Martin Dempsey, chairman of the Joint Chiefs of Staff, addresses U.S. troops in Iraq last fall. He has advocated a cautious approach to the battle there against the Islamic State. (D. Myles Cullen/Defense Department via AP)

In the summer of 2014, President Obama and his senior aides were scrambling to respond to the lightning advance of Islamic State fighters across Iraq and the collapse of local forces in the face of the onslaught.

Gen. Martin Dempsey, Obama’s top military adviser, recommended sending U.S. Special Forces troops to take stock of the situation. But Dempsey, unlike other aides who favored an immediate offensive response, also made a case for restraint, arguing that American air power should be unleashed in earnest only after the Iraqis struck a political agreement that would unify the country’s fractious leaders.

As the general liked to tell his aides: “Be quick, but don’t hurry.”

The recommendation underlined Dempsey’s instinct for caution — and belief in the limits of U.S. military power to counteract deep-seated sectarian and political rivalries across the Middle East. That perspective appears to have sat well with Obama, who has been determined to end the costly insurgent wars of the past decade and use force sparingly.

As Dempsey prepares to step down this fall after almost four years as chairman of the Joint Chiefs of Staff, however, the Obama administration’s deliberative foreign policy remains an object of frustration for critics, including some Democrats. In this view, the failure of the United States to more aggressively employ its military might — an approach Dempsey has played a key role in shaping — has left a power vacuum filled by the Islamic State and Iran.

“Dempsey had been a strong voice for the limits that should be placed on U.S. military power,” said a senior administration official, speaking on the condition of anonymity to discuss a senior officer.

For the general, the caution is hard-won, derived from his own history in Iraq and across the Middle East.

Unlike in the last war in Iraq, when U.S. troops bore the brunt of the battle against insurgents, Americans would remain in the background this time. Against the Islamic State, Dempsey believed that “the only way there’s a sustainable defeat is if the Iraqis feel the real weight of the problem,” the official said.

Dempsey is preparing to leave the Pentagon as renewed U.S. operations in Iraq, reluctantly approved by Obama last June, go on with no clear end in sight and with the Islamic State continuing to take ground, most recently in Ramadi.

While U.S. and allied airstrikes have helped Iraqi forces contain a broad militant advance, a small American force of 3,000 is only beginning to make headway in its effort to rebuild Iraq’s army for the second time. And Defense Secretary Ashton B. Carter warned in an interview on CNN this weekend that Iraqi troops have yet to develop a “will to fight.”

In a BBC interview, Iraqi Prime Minister Haider al-Abadi said he was sure that Carter “was fed with the wrong information.”

“They have the will to fight, but when they are faced with an onslaught by [the Islamic State] from nowhere . . . with armored trucks packed with explosives — the effect of them is like a small nuclear bomb — it gives a very, very bad effect on our forces,” he said.

The prime minister promised to retake Ramadi “in days.”

Vice President Biden spoke to Abadi on Monday and attempted to take some of the sting out of Carter’s remarks. According to a White House readout of the call, Biden “recognized the enormous sacrifice and bravery of Iraqi forces over the past eighteen months in Ramadi and elsewhere.”

‘Steady-as-a-rock Marty’

Within the Pentagon, Dempsey has been known for his plain talk, dry humor and low-key style. Unlike some “media generals” who have sought the spotlight, Dempsey has gone to lengths to ensure that his advice to Obama has remained private, a practice that has enhanced his standing with a White House known for its distaste for leaks.

The general declined to be interviewed for this article.

In some ways, Dempsey isn’t the typical battle-hardened leader. A New Yorker who spent childhood summers with relatives in Ireland, he is a onetime English professor who wrote his master’s thesis on Irish literature. He describes himself as a poet and has a penchant for singing Sinatra and Irish pub tunes with foreign dignitaries.

But as a rising Army star, Dempsey spent the better part of a decade immersed in military matters related to the Middle East, first as a military adviser to Saudi Arabia’s National Guard and, after Iraq, as deputy and acting commander of U.S. Central Command, responsible for the Middle East and parts of South and Central Asia.

Moving from the Persian Gulf kingdom, the seat of Sunni Muslim influence, to majority-Shiite Iraq, Dempsey came to see the depth of the region’s sectarian rivalries.

In Baghdad following the U.S.-led invasion in 2003, Dempsey, a brigadier general and commander of the Army’s 1st Armored Division, was tasked with stabilizing a city unmoored by the invasion. American troops not only confiscated weapons and searched for militants, but also tried to restore a semblance of normality, escorting garbage trucks and standing up municipal governments.

By April 2004, Dempsey’s troops were wrapping up a one-year tour; some had already rotated back to Germany. But insurgent violence was also gaining momentum.

Facing increasing bloodshed, military leaders ordered the division to scrap its redeployment plans and sent the troops instead into a fierce battle south of Baghdad. There, they fought to pacify areas controlled by the Mahdi Army, the militia loyal to Shiite cleric Moqtada al-Sadr. By the time the division left Iraq later that summer, 133 of Dempsey’s troops had been killed.

Dempsey received accolades for his handling of the last-minute decision to send his troops to stanch that escalating violence. “There was no anger, no emotions,” said one former senior officer who worked closely with him. “It was steady-as-a-rock Marty.”

Retired Gen. John Abizaid, a longtime mentor to Dempsey and former head of Central Command, said he had seen plenty of division commanders. Dempsey “was the best combat division commander of the war that I saw,” he said.

On Dempsey’s Pentagon desk today sits a box filled with laminated cards showing each of his soldiers killed in 2003-2004, a reminder of the human toll the war would take.

But for Dempsey and other commanders, those early years in Iraq also told a cautionary tale: The United States was unprepared for the effects of the invasion, which unleashed a chain reaction of local grievances that quickly spun out of control.

As head of the U.S. effort to rebuild Iraqi security forces in 2005, Dempsey struggled to ensure that new security institutions would reduce, rather than inflame, sectarian tensions. Iraq’s police force in particular was overrun by militias, and the Ministry of Interior was believed to be running sectarian death squads.

While many American officials found it difficult to get access to then-Prime Minister Nouri al-Maliki, it was different for Dempsey. The Iraqi leader always wanted to see the man he called “Abu Fulous,” or “father of money,” a reference to the weapons and funding Dempsey could provide to troops under Maliki’s command.

To Dempsey and many other officials, the muscular U.S. presence lessened Iraqis’ ownership of the crisis consuming the country.

“One of the things he believes is that perhaps we did too much for [the Iraqi government] in the past,” the administration official said.

‘A region in chaos’

Dempsey’s views on the escalating violence facing U.S. commanders in 2006 also produced lasting friction with John McCain, the hawkish senator who now chairs the Senate Armed Services Committee. While some military officials, and lawmakers including McCain, were advocating for a wave of additional U.S. troops to be sent to Iraq, Dempsey argued that local forces should constitute the front line against insurgents.

McCain, Dempsey’s biggest critic in Washington, has not let the general forget their disagreement over the 2007 troop surge or his handling of recent events in the Middle East.

Speaking in an interview, McCain said that an examination of the Middle East today reveals “a scenario that could not be described as anything but a region in chaos. And he was the president’s principal military adviser.”

At times, Obama has chosen not to heed the advice of his top advisers. At least twice, Dempsey and other senior aides have supported military action against the regime of Syrian President Bashar al-Assad. In 2012, Obama decided against setting up a military training program for Syrian rebels. In 2013, after a chemical weapons attack, Obama made a last-minute decision to embrace a diplomatic initiative instead of strikes on regime targets. Dempsey supported the disarmament program when it emerged.

Dempsey has not shied away from pushing for greater flexibility in Iraq. In September, he made ripples when he suggested that the United States might eventually need to send troops closer to the front lines, despite Obama’s vow that no American soldier would return to combat there. With Ramadi in militant hands and an offensive to reclaim Mosul seemingly months away, Dempsey’s aides say he has no immediate plans to recommend such a step.

For now, rather than taking the path chosen by his predecessor, Obama is following the course laid out by Dempsey last summer.

“During the crucible of those months last summer, all of his Iraq experience came to bear,” a second administration official said of the chairman.

“What we’re trying to do with the Iraqis is what he said we should have done back then.”