(Jenny Starrs/The Washington Post)

The Iranian-supplied rockets were raining down on Gen. James N. Mattis’s troops throughout the spring and summer of 2011 with greater and greater intensity.

Six American soldiers were killed by a volley in eastern Baghdad in early June. A few weeks later, three more Americans died in a similar strike, driving the monthly death toll to 15. It was the worst month for U.S. troops in Iraq in more than two years, and Iran’s proxies were vowing more rockets and more bloodshed.

Mattis, the top American commander in the Middle East, was determined to send a clear message to Tehran to stop it. His proposal, crafted with the support of the ambassador and the senior American commander in Iraq, was to hit back inside Iran, said current and former senior U.S. officials, who took part in the debate.

One option was a dead-of-night U.S. strike against an Iranian power plant or oil refinery, said the officials, speaking on the condition of anonymity to discuss sensitive operations.

“You could let them know that we have rockets, too,” one senior U.S. official said of the options forwarded by Mattis to Washington.

Now-retired Marine Gen. James N. Mattis’s advocacy and aggressive style alienated the Obama White House and the president he was serving. (Matt Dunham/Associated Press)

Mattis’s proposals quickly reached the White House, which had a different view of how to curb Iran’s increasingly aggressive behavior. To President Obama, a U.S. strike on Iranian soil would only inflame a volatile situation and widen a conflict that he had promised to end. Others in the White House worried that Mattis’s proposal risked starting yet another war in the Middle East.

The battle over how to respond to the mounting American casualties in summer 2011 reflected the deepening divide between the president and his top commander in the Middle East. In a White House worried about American overreach and the unintended consequences of military action, Mattis was the voice from the field consistently calling for a tougher response.

“There were clearly White House staff who thought the recommendations he was making were too aggressive,” said Leon E. Panetta, who was defense secretary at the time. “But I thought a lot of that was, frankly, not having the maturity to look at all of the options that a president should look at in order to make the right decisions.”

Ultimately, Mattis’s advocacy and aggressive style alienated the White House and the president he was serving.

Now Mattis will play a different role for a new commander in chief. As President-elect Donald Trump’s choice to lead the Pentagon, Mattis will oversee a force of nearly 1.3 million active-duty troops scattered across more than 150 countries. He will serve a president who has questioned the impartiality of America’s intelligence agencies and has moved in often puzzling ways to embrace longtime adversaries, such as Russian President Vladimir Putin. He has emphasized the value of unpredictability over careful deliberation and raw power over diplomacy.

Mattis’s falling out with the Obama administration, especially over Iran, offers a perspective into how the retired four-star Marine general will lead the world’s largest military and the advice he will bring to Trump during the most sensitive Situation Room debates.

The heated discussions in 2011 over how to respond to the Iranian rockets stretched on for weeks.

“There were concerns about proportionality, effectiveness and whether the Iranians would escalate,” said one former Pentagon official who took part in the discussions. “Could you actually hit the guys who were responsible as opposed to some random entity? Would it be anything more than a pinprick? How do you do something more than a pinprick without starting a conflict?”

In the end, Mattis was authorized to take action inside Iraq against the leaders of the Iranian-backed militias.

Senior White House officials said the American military response effectively deterred the Iranians and slowed the rocket attacks that were killing U.S. soldiers and Marines. Only 10 Americans died in Iraq during the last five months of 2011.

“It was a very tough, tough period,” a former senior White House official said. “And it was a very tough response.”

Mattis and some of his allies who favored a cross-border operation had a different takeaway. The American response slowed the attacks against U.S. troops in Iraq, but it also demonstrated that the Obama White House was unwilling to take the fight directly to the Iranians, even when they drew American blood.

“The American response solved the immediate problem of Iranian-backed attacks, but was not sufficient to deter Iran from further challenges to the U.S. military throughout the region,” one senior U.S. official involved in the deliberations said.

3 priorities: Iran, Iran, Iran

For much of the Obama presidency, Iran loomed as one of the toughest and most volatile foreign policy problems. A big part of that challenge was managing Israel, the United States’ closest ally in the region, but one that might take unilateral action against Iran.

Israeli leaders were sending mixed messages to Obama and his top advisers about how far they were willing to go to stop Iran from acquiring a nuclear weapon. Then-Defense Minister Ehud Barak briefed his Pentagon counterparts on secret plans to launch a commando-style raid on Iran’s most heavily fortified nuclear site. Israel’s Mossad intelligence service, in turn, privately told the Americans that the Israelis could not act against Iran alone. The White House was never certain whom to believe.

Mattis’s job at Central Command was to be prepared if Israel triggered a war and to signal to the Iranians that the outcome of any wider conflict with the United States would be devastating for them. It was a responsibility that Mattis took seriously, sometimes too seriously for those at the White House and the State Department, current and former officials said.

Soon after Mattis was tapped to lead U.S. forces in the Middle East in August 2010, Obama asked the general to spell out his top priorities. Mattis replied that he had three: “Number one Iran. Number two Iran. Number three Iran,” said a senior U.S. official who was present. The general’s singular focus unnerved some civilian leaders, who thought he should pay attention to a broader range of threats.

His style and Marine swagger often struck the wrong chord in a White House that was focused on diplomacy and that was notably short of top officials with military experience. Mattis and his aides relentlessly drilled the U.S. military’s war plan for Iran. During one planning session, which focused on the war’s aftermath and included senior officials from Washington, Mattis repeatedly joked that Iran’s navy would be at “the bottom of the ocean,” participants said.

His preparations for a possible conflict also rattled some U.S. diplomats whom Mattis invited to Central Command’s regional headquarters in Qatar in 2011 for briefings on how Iran might strike back at U.S. allies and facilities. Some of the diplomats had the impression that Mattis was describing a “World War III” scenario, one ambassador said.

Among the greatest dangers in the region was uncertainty, and some White House officials worried that Iran might misread Mattis’s war preparations as an act of aggression. At the time, the United States had no direct channels of communication with the Iranian military to de-escalate tensions.

On occasion, the U.S. military would conduct exercises designed to send messages to the Iranian Revolutionary Guard Corps about America’s seriousness. During and after those maneuvers, U.S. spy agencies would monitor the Iranians’ reactions. Sometimes the Iranians missed the intended signal, suggesting to the Americans that they did not notice what the United States had done. At other times, they seemed to react to American actions that were not intended to be provocative.

“The fog of war was enormous,” a former senior Pentagon official said.

Mattis proposed opening a direct channel with the Iranian military to mitigate the risk of miscalculation. But the White House, worried about sparking a diplomatic backlash, rejected the proposal.

In this atmosphere of growing tension, Mattis began pressing for more authority to hit the Iranians hard if it looked as though Tehran was shifting to a war footing. Iran’s first move in a fight with the United States or Israel probably would be to drop mines into the Strait of Hormuz, choking off the Middle East’s oil supply.

Mattis asked for permission to strike Iranian fast boats as soon as the United States had solid intelligence that the Iranians were loading them with mines. His rationale was that the boats were most vulnerable when they were still in port and that a swift blow could cripple Iran’s war effort before it had even started.

“His number one objective was to prevent the war from breaking out by being ready to preempt the Iranians,” a former senior military officer said. “If he had taken the Iranian swarm boats out with mines in them, then that was going to be it for them.”

The White House worried that bad intelligence or a rash judgment could trigger an unnecessary war with Iran. “It’s understandable that if we were going to engage in an act of war in the Strait of Hormuz that the president ought to play a key role,” Panetta said.

But, Panetta added, it also was Mattis’s job to offer the president his best military advice and options. The United States would have only a few hours to act after Iran began loading the mines. Once the mines were in place, Mattis knew reopening the strait could take three weeks and lead to U.S. casualties.

The end result of the heated debate in late 2011 and early 2012 was a compromise: Obama would bypass the White House’s careful and cumbersome policy process and decide on an expedited basis whether to strike the fast boats, Panetta said.

America’s ‘sentinel’

Mattis’s bold moves were seen as helpful when the White House was trying to press Iran into talks to curb its nuclear program. His brash style was also a reassurance to Israeli leaders threatening to launch unilateral strikes. The Israelis may have questioned Obama’s willingness to use force against Iran to prevent it from building a nuclear bomb. But they believed Mattis was serious.

In time, however, as secret talks with Iran got underway in the summer of 2012, some White House officials began to see Mattis as a potential liability.

Each week, Mattis wrote a classified letter to the defense secretary that was forwarded to the White House. Typically, Mattis’s updates focused on Iran’s support for terrorism and its destabilizing activities throughout the region. To the White House, these threats were secondary to restricting Iran’s nuclear program, and Mattis’s hard-nosed approach, as outlined in the weekly letters, was seen by some as out of step with the president’s top foreign diplomatic priority.

Eventually, higher-ups in the Pentagon encouraged Mattis to shift his focus away from Iran and concentrate on the rest of the Central Command region, which encompassed all of the Middle East as well as Afghanistan and Pakistan. “The feedback was to tone down the Iran stuff in the letter,” one former military official said. “Basically, they said it wouldn’t hurt to talk about something else.”

Mattis often said it was his role to act as America’s “sentinel” in the Middle East. He refused to soften his assessments.

“It was a kind of culture clash,” said Dennis Ross, who advised Obama on Iran policy. “There was such a preoccupation in the White House with not doing things that would provoke Iran or be seen as provocative. Mattis was, by definition, inclined toward doing those things that would be seen as provocative. And as time went by, this became increasingly less acceptable to them.”

In early 2013, the general was told he was being replaced five months early. Inside the White House, Mattis’s early departure was not viewed as a firing. He had not behaved unethically or rebelled against his civilian chain of command.

“Jim Mattis was not a runaway general,” said Matthew Spence, a senior administration official who worked closely with Mattis. “There was a very unfair impression that he was coming out of the trenches and only saying go, go, go. In reality, he was one of the most thoughtful strategists in uniform that I have ever worked with.”

But Mattis had a different view of his departure. He was convinced that he had been dismissed early for running afoul of the White House, friends and former colleagues said.

Now Mattis is poised to serve a new commander in chief whose brash approach could force the former general into a new and unfamiliar role. When Iranian naval vessels were harassing American warships this summer in the Strait of Hormuz, Trump responded with a verbal broadside.

“When they circle our beautiful destroyers with their little boats and they make gestures at our people that they shouldn’t be allowed to make, they will be shot out of the water,” Trump said to thunderous applause at a campaign rally.

As defense secretary, Mattis may be compelled to act as a check on an inexperienced president’s instincts. There are already some signs that he is thinking along these lines and indications that his task will not be an easy one.

Shortly after Trump tapped him to lead the Pentagon, Mattis asked Michèle Flournoy, the front-runner for the defense secretary job in a Hillary Clinton White House, to consider serving as his deputy.

Mattis’s courtship of Flournoy suggested a bias for continuity over radical change and underscored his determination to be an independent voice in White House policy debates.

Flournoy visited Trump Tower in New York to discuss the job with senior Trump foreign policy advisers. Soon after, she decided her differences with the president-elect were too deep to accept the position.

Several weeks later, Mattis is still searching for a deputy.

Read more:

At the Justice Department, Sessions could play a key role on immigration

Trump confidants serving as presidential advisers could face tangle of potential conflicts

Republican leaders cast doubt on Trump improving relations with Russia