Updated

A forthcoming memoir by Obama confidant Ben Rhodes includes the startling admission that the 44th president’s inner circle should have seen Hillary Clinton’s 2016 loss coming – because President Trump was essentially using the Obama playbook to discredit her.

The New York Times published excerpts of the book, "The World As It Is," which describes outgoing President Barack Obama’s shock and disbelief at Trump’s election victory.

But Rhodes also seems to acknowledge that Trump used some of the same lines of attack employed by Obama during the hard-fought 2008 presidential primary against Clinton – minus what Rhodes describes as the “racism and misogyny.”

“I couldn’t shake the feeling that I should have seen it coming,” Rhodes writes in the book. “Because when you distilled it, stripped out the racism and misogyny, we’d run against Hillary eight years ago with the same message Trump had used: She’s part of a corrupt establishment that can’t be trusted to bring change.”

Ben Rhodes FBN

Ben Rhodes says in a forthcoming memoir that they should have seen Hillary Clinton's loss coming. (AP)

Obama ran in 2008 as the “change” candidate, rallying an enthusiastic base to defeat Clinton in the primary and later GOP nominee John McCain. In 2016 as in 2008, Clinton entered the race as the establishment favorite, only to be sidelined by an insurgent political newcomer.

Despite that admission by Rhodes, the book describes how Obama was distraught at the outcome.

“What if we were wrong?” Obama reportedly asked aides, as he struggled to come to terms with Clinton's defeat.

Obama remained alternately optimistic and dejected, according to Rhodes, who has been feted as an aspiring novelist-turned national security wunderkind.

“Sometimes I wonder whether I was 10 or 20 years too early,” Obama told aides, according to the memoir. “Maybe we pushed too far. ... Maybe people just want to fall back into their tribe.”

Rhodes was promoted from presidential speechwriter to deputy national security adviser under Obama. He held that post during the raid that killed Usama bin Laden, as well as the U.S. intervention in Libya and the signing of the Iran nuclear deal.

The possibility that Trump could unravel that legacy apparently weighed on Obama, Rhodes writes.

FMR OBAMA OFFICIALS FORM ANTI-TRUMP THINK TANK

“I feel like Michael Corleone," Obama reportedly said, referencing "The Godfather" character as he prepared to hand over the White House to Trump. "I almost got out.”

According to Rhodes, he and Obama were not aware that the FBI had begun an investigation into the Trump campaign's dealings with Russia until after the election.

The book also touches on some foreign-policy melodrama as Obama made his exit from the world stage, amid a shifting geopolitical climate that included Brexit and rising disenchantment with globalism.

Chancellor Angela Merkel of Germany had a "single tear in her eye" when she and Obama parted for the last time, and Obama noted that "she's all alone" to defend his liberal principles, according to Rhodes.

BEN RHODES JOKES ABOUT GOP LEADERS' 'OBITS'

In footage from an HBO documentary recording on election night in 2016, Rhodes himself was seen sitting alone outside on a bench, haltingly repeating that the situation was difficult to "process."