Hillary Clinton is seen aboard the campaign bus in Cleveland on the third day of a bus tour through Pennsylvania and Ohio.

July 31, 2016 Hillary Clinton is seen aboard the campaign bus in Cleveland on the third day of a bus tour through Pennsylvania and Ohio. Melina Mara/The Washington Post

The former secretary of state, senator and first lady is the Democratic nominee for president.

The day after the Affordable Care Act passed the House, several of President Obama’s top advisers met in the Situation Room. Then-Secretary of State Hillary Clinton was “buoyant,” and she congratulated everyone in the room, recalled former White House adviser David Axelrod. Then Obama walked in, and Clinton — who had tried and failed to pass comprehensive health-care reform when her husband was president in the 1990s — gave him a big hug.

Eight years ago, Clinton and Obama were competitors who had taken several well-publicized swipes at each other, and whose surrogates had engaged in much worse. But that unguarded moment at the White House, when Clinton affectionately acknowledged that her 2008 presidential rival had succeeded where she had failed, reflected the evolution of an alliance that has defied expectations.

Now, after dutifully supporting Obama’s presidency, Clinton is ready to reverse the roles. And as she assumes the mantle of the Democratic Party’s standard bearer, no single relationship may be more important to realizing her current aspirations than the one she has forged with Obama.

Clinton and Obama have already met a couple of times at the White House since she launched her presidential bid — sessions that were disclosed after the fact. They chat by phone periodically — including on Tuesday night, when Obama called to congratulate her on clinching the nomination.

The president hasn’t provided tactical advice, according to an individual familiar with the conversations, but he has offered broad guidance about the importance of Clinton staying true to her own values and the issues that matter. But his role is likely to change dramatically in the coming days and weeks — and Clinton’s team can’t wait.

In this image digitally altered by the source to diffuse the paper in front of then-Secretary of State Hillary Clinton, President Obama and Vice President Biden, along with members of the national security team, receive an update on the mission against Osama bin Laden in the Situation Room in May 2011. (Pete Souza/White House via AP)

Many of her top staffers served as senior Obama administration officials, and they believe the president’s political gifts and enduring popularity will only help her in the general-election contest against Donald Trump. Several Democrats said the president probably will serve a similar role to the “explainer in chief” function that Bill Clinton played for Obama in 2012, pointing out flaws in the Republicans’ arguments.

[In break with protocol, Obama criticizes Trump while overseas]

Obama would be a “uniquely valuable voice” in support of Clinton, campaign press secretary Brian Fallon said.

“He came away from the 2008 campaign with enough respect to make her a part of his Cabinet” and relied on her advice when she accepted, Fallon said. “He has already shown in recent appearances that he is an effective messenger in terms of explaining the danger Donald Trump poses.”

Obama’s and Clinton’s comfortable rapport, in which the president is offering insights on how to navigate rocky political shoals, was not inevitable.

Former congressman Barney Frank (D-Mass.), a Clinton supporter, said it was understandable that the two politicians emerged from their lengthy primary battle with bruised feelings.

“First of all, nobody likes the person you’re running against,” he said. “One of the biggest lies in politics is, ‘We ran against each other, but we’re good friends.’ ”

[Next for Democrats: A delicate dance to broker peace between Clinton and Sanders]

There were some particularly sharp moments, such as when Obama told Clinton she was “likeable enough,” or when Clinton remarked that her rival’s willingness to meet without preconditions with the leaders of hostile nations such as Iran, Cuba and North Korea “was irresponsible and frankly naive.”

But the breach was repaired as both Clinton and her husband worked to mobilize voters on Obama’s behalf once she had conceded the nomination. And her move that year to nominate Obama for president by acclamation at the Democratic National Convention smoothed the way for them to cooperate on the campaign trail.

Still, Axelrod, who helped Obama win the White House and retain it four years later, said the president’s selection of Clinton to serve as his secretary of state “was surprising to a lot of us, because we had just run a two-year campaign that was very competitive.” Over time, however, he and others observed them develop a true affinity.

“There was a genuine relationship there rooted in respect, admiration and friendship,” he said. “They came to symbolize that element of our democracy.”

When Clinton addressed foreign audiences, she often used her own example to describe how the American system works. “He won, I lost, and I went to work for him,” she would say. No one staged a revolt. No one died. No one went to jail.

Initially, Clinton allies largely saw the post as a reward that carried some risks. She would be in the public eye, always a double-edged sword, and she would be lashed to Obama’s foreign-policy decisions for good or ill.

At times, Clinton fretted about her role within Obama’s inner circle. In an exchange released last year in connection with a probe of her private email server, she asked aides why she had arrived for a morning meeting at the White House only to discover it was canceled.

“This is the second time this has happened,” she wrote. “What’s up???”

The job ended up producing Clinton’s highest approval ratings of her long public career — numbers her closest aides at the time said could never last — and also some of the largest liabilities she now faces as a candidate. Her private email server is the subject of an FBI inquiry. She was in charge when four Americans died at poorly secured U.S. facilities in Benghazi, Libya.

The relationship was not without its disagreements over policy or approach to foreign crises. But over the four years of her tenure, her relationship with Obama became one of deep admiration and trust on both sides. When she left, in early 2013, she did so with Obama’s implicit endorsement as his successor. They gave a joint television interview — the only such session he had ever done — in which he declared, “I think Hillary will go down as one of the finest secretary of states we’ve had.”

[With legacy in the balance, Obama tries to shore up Democrats in 2016]

Each said they relied on the advice and perspective of the other, and they displayed an easy familiarity that suggested they could speak frankly with one another.

In recent years Obama has made a point of praising the toughness of Clinton and another prominent female Democrat he’s worked with most closely, House Minority Leader Nancy Pelosi (Calif.), saying that female politicians of their generation have faced challenges their male counterparts did not.

Reflecting on the 2008 race in an interview in January with ­Politico’s Glenn Thrush, the president remarked, “I mean, we had as competitive and lengthy and expensive and tough primary fight as there has been in modern American politics, and she had to do everything that I had to do, except, like Ginger Rogers, backwards in heels.”

“She had to wake up earlier than I did because she had to get her hair done. She had to, you know, handle all the expectations that were placed on her,” he continued. “She had a tougher job throughout that primary than I did and, you know, she was right there the entire time and, had things gone a little bit different in some states or if the sequence of primaries and caucuses been a little different, she could have easily won.”

Frank noted that the race eight years ago was “a pair of firsts, the first African American president versus the first woman president.” If Obama can help Clinton this time around, Frank added, the president “won’t go into the history books as the guy who prevented the first woman president” from taking office.

While riding on Marine One on Wednesday, Obama discussed with his aides how he “was struck by the historic nature of last night’s speech,” White House press secretary Josh Earnest said. “Regardless of which candidate you intend to support in the fall, the fact that we have a woman who’s . . . been nominated by a major party as a candidate for president of the United States is a history-making moment.”

Republicans have argued that the drawn-out primary season has exposed Clinton’s vulnerabilities as a candidate along with the public’s unease with establishment politicians, two factors that Obama’s support alone cannot overcome.

But the president has already played a central role in her campaign narrative. Clinton has made the story of her selection as Obama’s top diplomat a standard part of her stump speech. He had to ask her more than once, she says, and he would not take no for an answer. She praises him, often extensively, for his work to right the U.S. economic ship in 2009, and for what she calls crisp and principled decision-making. Lately, she uses the example of the raid that killed Osama bin Laden to draw a comparison between Obama’s leadership style and what the country might get under Trump.

Clinton and Obama are poised to forge the closest campaign relationship between a two-term president and a potential successor in a generation. Then-Vice President Al Gore famously avoided campaigning with Bill Clinton in 2000, in the aftermath of the president’s impeachment.

In 1988, George H.W. Bush consciously aligned himself with Ronald Reagan to capi­tal­ize on Reagan’s popularity, but the two were not close. And while Bush struggled to overcome Reagan’s shadow, Clinton has not suffered from “the second banana” problem many vice presidents and other Cabinet members have experienced in similar situation, said David Karol, a political science professor at the University of Maryland.

“People don’t see her as an obsequious person, even the people who don’t like her,” he said. “That’s not her problem.”