Barack Obama. REUTERS/Yuri Gripas President Barack Obama said in an interview published on Sunday that he believes the rise of Donald Trump can be traced back to another Republican firebrand — former vice presidential nominee Sarah Palin.

Obama spoke with New York Magazine about the final days of his presidency and reflected on the current state of US politics.

He explained how, during the first months of his presidency, he realized that Palin, the former Alaska governor whom Sen. John McCain of Arizona chose to be his running mate during the 2008 election, had tapped into a certain segment of the Republican Party that hadn't been so visible.

"What you realized during the course of the first six, eight, 10 months of the administration was that the attitudes, the moods that I think Sarah Palin had captured during the election increasingly were representative of the Republican activist base, its core," Obama said.

The president continued: "It might not have been representative of Republicans across the country, but it meant that [former House Speaker] John Boehner or [Senate Majority Leader] Mitch McConnell had to worry about that mood inside their party that felt that, 'No, we shouldn't cooperate with Obama, we shouldn't cooperate with Democrats'; that it represents compromise, weakness, and that the broader character of America is at stake, regardless of whatever policy arguments might be made."

Trump, the Republican nominee for president, seems in some ways to be an extension of that mood, according to Obama.

"I see a straight line from the announcement of Sarah Palin as the vice presidential nominee to what we see today in Donald Trump, the emergence of the Freedom Caucus, the tea party, and the shift in the center of gravity for the Republican Party," Obama said. "Whether that changes, I think, will depend in part on the outcome of this election, but it's also going to depend on the degree of self-reflection inside the Republican Party."

He continued: "There have been at least a couple of other times that I've said confidently that the fever is going to have to break, but it just seems to get worse."