President Donald Trump used a rare primetime speech Monday night to tell the American people that the Afghan war — already the longest conflict in US history — was going to continue into the indefinite future.

“The consequences of a rapid exit are both predictable and unacceptable,” the president said in the speech. “A hasty withdrawal would create a vacuum that terrorists, including ISIS and al Qaeda, would instantly fill.”

Perhaps the most striking thing about the speech, which was deliberately light on policy specifics like how many more troops would be deployed to Afghanistan, was that Trump had vocally and repeatedly criticized the war in Afghanistan in the harshest possible terms for years before taking office.

“I think the same as what I’ve been thinking for the past couple of years: What are we doing there? These people hate us,” Trump said in a 2012 Fox News appearance. “We’re spending hundreds of billions of dollars, trillions of dollars, on this nonsense — and the minute we leave, everything blows up, and the worst guy gets it. The one who hates this country the most will end up taking over Afghanistan.”

Roughly 2,350 Americans have died in Afghanistan, and the war has cost more than $1 trillion. Trump’s former chief strategist, Steve Bannon, had reportedly argued against continuing the war on the grounds that it was too costly and had accomplished very little — the precise arguments the president himself had made the past.

Trump acknowledged the contradiction in his speech. “My original instinct was to pull out, and historically I like following my instincts,” he said. “But all my life, I have heard that decisions are much different when you sit behind the desk in the oval office.”

But the word “instinct” underplays things. For the past several years, the president has been a staunch, consistent advocate for withdrawing from Afghanistan. Opposition to the war seemed, for the all the world, like a core policy position of his — one that he’s now reversing.

The best way to see this, as is often the case with Trump, is to look at Twitter. I searched Trump’s Twitter account — @realdonaldtrump — for every tweet mentioning the word “Afghanistan.” The result was dozens of tweets about the war, virtually all of which were criticizing the US effort there and calling for the troops to come home.

Here’s a sample:

Ron Paul is right that we are wasting trillions of dollars in Iraq and Afghanistan. — Donald J. Trump (@realDonaldTrump) August 13, 2011

Ron Paul is right when he says we are wasting lives and money in Iraq and Afghanistan. — Donald J. Trump (@realDonaldTrump) August 17, 2011

When will we stop wasting our money on rebuilding Afghanistan? We must rebuild our country first. — Donald J. Trump (@realDonaldTrump) October 7, 2011

It is time to get out of Afghanistan. We are building roads and schools for people that hate us. It is not in our national interests. — Donald J. Trump (@realDonaldTrump) February 27, 2012

China is getting minerals from Afghanistan http://t.co/uNxQYQWi We are getting our troops killed by the Afghani govt't. Time to get out. — Donald J. Trump (@realDonaldTrump) February 29, 2012

Afghanistan is a total disaster. We don't know what we are doing. They are, in addition to everything else, robbing us blind. — Donald J. Trump (@realDonaldTrump) March 12, 2012

No wonder Afghanistan is a mess! @BarackObama is releasing high level insurgents in exchange for pledges of peace. http://t.co/clTDHlZ8 — Donald J. Trump (@realDonaldTrump) May 7, 2012

Why are we continuing to train these Afghanis who then shoot our soldiers in the back? Afghanistan is a complete waste. Time to come home! — Donald J. Trump (@realDonaldTrump) August 21, 2012

So Obama and Congress can waste billions in Iraq & Afghanistan building roads & schools but can’t get money to the NJ & NY Sandy victims? — Donald J. Trump (@realDonaldTrump) January 3, 2013

Let’s get out of Afghanistan. Our troops are being killed by the Afghanis we train and we waste billions there. Nonsense! Rebuild the USA. — Donald J. Trump (@realDonaldTrump) January 11, 2013

I agree with Pres. Obama on Afghanistan. We should have a speedy withdrawal. Why should we keep wasting our money -- rebuild the U.S.! — Donald J. Trump (@realDonaldTrump) January 14, 2013

We should leave Afghanistan immediately. No more wasted lives. If we have to go back in, we go in hard & quick. Rebuild the US first. — Donald J. Trump (@realDonaldTrump) March 1, 2013

Our gov't is so pathetic that some of the billions being wasted in Afghanistan are ending up with terrorists http://t.co/bso3k1pR7l — Donald J. Trump (@realDonaldTrump) April 17, 2013

Do not allow our very stupid leaders to sign a deal that keeps us in Afghanistan through 2024-with all costs by U.S.A. MAKE AMERICA GREAT! — Donald J. Trump (@realDonaldTrump) November 21, 2013

We have wasted an enormous amount of blood and treasure in Afghanistan. Their government has zero appreciation. Let's get out! — Donald J. Trump (@realDonaldTrump) November 21, 2013

Can you believe that "President" Karzai of Afghanistan is holding out for more, more, more and refuses to sign deal. Tell him to go to hell! — Donald J. Trump (@realDonaldTrump) November 28, 2013

Five U.S. soldiers killed in Afghanistan by so-called friendly fire. What are we doing? — Donald J. Trump (@realDonaldTrump) June 10, 2014

Now Obama is keeping our soldiers in Afghanistan for at least another year. He is losing two wars simultaneously. — Donald J. Trump (@realDonaldTrump) December 1, 2014

A suicide bomber has just killed U.S. troops in Afghanistan. When will our leaders get tough and smart. We are being led to slaughter! — Donald J. Trump (@realDonaldTrump) December 21, 2015

The clear through-line — aside from the fact that the president seems to have believed “Afghani,” the name of Afghanistan’s currency, is actually the name of its people — is that Trump thinks the US needed to withdraw its troops from Afghanistan. There’s no doubt or room for interpretation: His tweets make that crystal clear.

Nor is this something that he tweeted once in an offhanded way, as the “instinct” phrasing in his speech suggested. This was a belief the president expressed repeatedly for four years on Twitter, one that appears to be about as deeply held as Trump is capable of getting. And yet, he’s decided to go back on it.