President Barack Obama is Hillary Clinton's most important supporter now that her campaign for the presidency is moving past Democratic Party infighting and is focusing on the general election in November, but their relationship was not always so cozy. Just eight years ago, it was downright hostile.

After remaining neutral during months of primary elections, caucuses and campaigning, Obama enthusiastically and emphatically endorsed Clinton once political experts said she was all but certain to win the party's nomination at its national convention next month.

FILE - In this Dec. 1, 2008, file photo, then-President-elect Barack Obama, left, stands with then-Sen. Hillary Rodham Clinton, D-N.Y., after announcing that she is his choice as Secretary of State during a news conference in Chicago.

The president said his support was based on Clinton's judgment about issues of national importance and her “commitment to our values."

“Look, I know how hard this job can be," Obama said in a campaign video released Thursday by the Clinton campaign. "That’s why I know Hillary will be so good at it. In fact, I don’t think there’s ever been someone so qualified to hold this office.

“I’m with her. I’m fired up, and I can’t wait to get out there and campaign for Hillary.”

Eight years is a long time in U.S. politics, though. The president's exuberant comments this week contrasted sharply with his less-than-flattering words about Clinton in 2008. Democratic Party infighting then was all about the battle between a young African-American senator from Illinois and his congressional colleague from New York, a former first lady with eight years of White House experience at her husband's side.

The 2008 campaign made clear that U.S. Democrats would put forward a unique and unprecedented presidential candidate. Voters and party elders had not yet decided, however, whether that would be the first black man or the first woman to seek the nation's highest office with backing from a major political party.

At a rally in Iowa before the primary campaign had even gotten into full swing, Obama said Clinton voted and talked “just like George W. Bush,” the Republican president at the time.

He painted her as a Washington insider with loose political convictions, and that became a cornerstone of his campaign. A leaked strategy plan by the Obama campaign showed the plan to defeat Clinton in the primaries was to challenge her “character fault line.”

Several of Obama’s close advisers urged him to highlight her shifting positions on issues such as the Trans-Pacific Partnership, which she initially supported but then opposed, or gay marriage, a policy that she had first opposed, then supported.

Back in 2008, Obama said he was not in favor of same-sex marriage, although he supported other civil rights for gay couples. In fact, he had flipped his own position once before — declaring himself a supporter of same-sex marriage in 1996, then saying years later he opposed it on religious grounds. President Obama reversed course again in 2012, when he told the nation he had gone through "an evolution" on the issue, and now supported marriage rights for homosexual and lesbian couples.

Clinton's switch to support for gay marriage in 2008 may have had something to do with her aggressive campaign against Obama. The future president's advisers certainly thought so.

“She’s driven by political calculation, not conviction, regularly backing away and shifting positions on issues ranging from war, to Social Security, to trade, to reform,” they wrote in their strategy memorandum. “She prides herself on working the system, not changing it — rebuffing reforms on everything from lobbyist donations to budget earmarks.”

The strategy worked for Obama then, as he went on to defeat Clinton decisively before the party convention. Almost eight years to the day after she announced her 2008 presidential candidacy was over, the American political establishment confirmed her victory over Bernie Sanders, the senator from Vermont, in the 2016 race.

Now it appears that Obama's 2008 strategy against Clinton is being taken up by her expected Republican opponent in the general election, Donald Trump.

Trump posted a video Friday on Facebook that was linked to an Obama radio ad from 2008, with the caption, “I rarely agree with President Obama — however he is 100% correct about Crooked Hillary Clinton. Great ad!”

The old attack ad criticized Clinton for supporting the North American Free Trade Agreement, the pact by the U.S., Mexico and Canada that then-Senator Obama asserted “cost South Carolina thousands of jobs.” She also was under fire for her vote in Congress in support of sending U.S. troops into war in Iraq years earlier. The message from the Obama team was that Clinton was “what’s wrong with politics today.”

Despite the heated campaign rhetoric, Clinton bowed out of the race gracefully when her path to the White House became mathematically impossible. And after meeting privately with Obama, she went on to become one of his most vocal supporters during the general election campaign.

Tommy Vietor, a spokesman and strategist for Obama in 2008, recently told National Public Radio the two senators were “able to talk through” their differences before the general election campaign eight years ago, and that Clinton’s speech endorsing Obama was “an enormous step forward in terms of bringing the party back together.”

The relationship between Obama and Clinton became much warmer, and quickly. Obama went on to defeat Republican nominee John McCain, a senator from Arizona, and take office as the 44th U.S. president, the first African-American to hold the office, in January 2009. The new president appointed Clinton to his Cabinet as secretary of state, and she traveled the world as America's top diplomat until 2013, when she stepped down to begin preparing for her own future presidential bid.

A few days before Clinton formally resigned, Obama told an interviewer (on CBS-TV’s 60 Minutes program) he thought she would go down in history as one of the finest secretaries of state the United States has ever had, and he praised their friendship.

“By the time Hillary joined the administration, I felt very confident and comfortable in our working relationship,” Obama said. “What did evolve was a friendship, as opposed to just a professional relationship. Friendships involve a sense of trust and being 'in the foxhole' [weathering opposition] together.”

Clinton said this week how much she valued the "strong, substantive endorsement" by the president.

"Obviously I value his opinion a great deal personally," she told an interviewer (Bloomberg News). "It's just such a treat, because over the years of knowing each other, we've gone from fierce competitors to true friends."