Donald Trump’s ascendance is nothing if not surprising.

Pundits thought he would flame out early; he has done things that could have ended other campaigns; and his statements are erratic and even sometimes contradictory. Yet, he remains the leading Republican presidential contender.

Many have tried to explain Trump’s rise in the nine months since he entered the race, and now President Obama can be counted among them: He offered up his analysis of Trump and the broader fight for the Republican presidential nomination during a speech Friday afternoon at a Democratic National Committee event at Texas’s Austin Music Hall.

"We’ve got a debate inside the other party that is fantasy and schoolyard taunts and selling stuff like it’s the Home Shopping Network,” he joked.

Obama said he was unsurprised by the billionaire businessman and reality TV star’s rise.

“How can you be shocked?” he asked to laughter from the crowd, according to a transcript. “This is the guy, remember, who was sure that I was born in Kenya — who just wouldn’t let it go. And all this same Republican establishment, they weren’t saying nothing. As long as it was directed at me, they were fine with it. They thought it was a hoot, wanted to get his endorsement. And then now, suddenly, we’re shocked that there’s gambling going on in this establishment,” he said in an apparent reference to a famous line from the movie classic "Casablanca."

The Republican Party set the conditions long ago for Trump’s success, Obama said. The billionaire just capitalized on the GOP’s own tactics, the president argued:

What is happening in this primary is just a distillation of what’s been happening inside their party for more than a decade. I mean, the reason that many of their voters are responding is because this is what’s been fed through the messages they’ve been sending for a long time — that you just make flat assertions that don’t comport with the facts. That you just deny the evidence of science. That compromise is a betrayal. That the other side isn’t simply wrong, or we just disagree, we want to take a different approach, but the other side is destroying the country, or treasonous. I mean, that’s — look it up. That’s what they’ve been saying.

So they can’t be surprised when somebody suddenly looks and says, you know what, I can do that even better. I can make stuff up better than that. I can be more outrageous than that. I can insult people even better than that. I can be even more uncivil. I mean, conservative outlets have been feeding their base constantly the notion that everything is a disaster, that everybody else is to blame, that Obamacare is destroying the country. And it doesn’t matter whether it’s true or not. It’s not, we disagree with this program, we think we can do it better — it’s, oh, this is a crisis!

So if you don’t care about the facts, or the evidence, or civility, in general in making your arguments, you will end up with candidates who will say just about anything and do just about anything. And when your answer to every proposal that I make, or Democrats make is no, it means that you’ve got to become more and more unreasonable because that’s the only way you can say no to some pretty reasonable stuff. And then you shouldn’t be surprised when your party ultimately has no ideas to offer at all.

Despite his strong critique of the GOP, though, Obama added a caveat:

There are thoughtful conservatives — good people in the Republican Party, good people who are Republican voters who care about poverty and they care about climate, and don’t resort to insults, and are troubled by what’s happening inside their own party. I know them. I’ve talked to them. But they’ve got to acknowledge why this happened — because some of them have been writing that, “Well, the reason our party is going crazy is because of Obama.” Which is a pretty novel idea. The notion is Obama drove us crazy.

Now, the truth is, what they really mean is their reaction to me was crazy and now it has gotten out of hand. But that’s different. I didn’t cause the reaction. The reaction is something that they have to take responsibility for and then figure out how do we make an adjustment.

Obama's analysis mirrors that of New Yorker editor David Remnick, who in the March 14th issue calls Trump "the beneficiary of a long process of Republican intellectual decadence.”

"Paul Ryan denounces Trump but not the Tea Party rhetoric that propelled his own political ascent," he writes. "John McCain holds Trump in contempt, but selected as his running mate Sarah Palin, the Know-Nothing of Wasilla, one of Trump’s most vivid forerunners and supporters. Mitt Romney last week righteously slammed Trump as a 'phony' and a misogynist, and yet in 2012 he embraced Trump’s endorsement and praised his 'extraordinary' understanding of economics."

Read more:

Trump: ‘I think you’d have riots’ if contested convention results in a different nominee

Trump has lit a fire. Can it be contained?