The US is planning a total withdrawal of its military forces from Syria, where they are nearing the end of the campaign to retake all of the territory once held by ISIS, according to reports.

President Trump, who has long advocated for the pullout from Syria, made the decision for the “full” and “rapid” withdrawal, a US defense official told CNN on Wednesday.

“We have defeated ISIS in Syria, my only reason for being there during the Trump Presidency,” the president tweeted Wednesday morning.

American officials have begun informing partners in northeastern Syria of plans to withdraw forces out of the area where they have been trying to wrap up the campaign against ISIS, sources told the Wall Street Journal.

The move follows a recent call between Trump and Turkish President Recep Tayyip Erdogan, who has threatened to launch an assault on Kurdish partners of the US in Syria.

The US has about 2,000 troops in Syria, many of them special forces training local forces to combat ISIS and working with an alliance of Kurdish and Arab militias known as the Syrian Democratic Forces, or SDF, according to Reuters.

The US-backed forces have had some recent success against ISIS and are on the verge of capturing the last major town held by the terror group east of the Euphrates, CNN reported.

Estimates vary as to how many ISIS jihadists are left in Syria. In the town of Hajin, the coalition estimated that about 2,000 ISIS fighters were present.

But according to a Defense Department inspector general report, the number of ISIS members in Syria and Iraq is as high as 30,000.

The partnership with the SDF has led to the defeat of ISIS in Syria but outraged NATO ally Turkey, which views Kurdish YPG forces in the alliance as an extension of an extremist group fighting inside Turkey, Reuters reported.

A US withdrawal would upend assumptions about a longer-term US military presence in the country, which Defense Secretary Jim Mattis and other senior US officials had called for to help ensure that ISIS cannot return.

Mattis and US State Department officials have long fretted about leaving Syria before a peace agreement can be reached to end the country’s brutal civil war.

In April, Mattis said: “We do not want to simply pull out before the diplomats have won the peace. You win the fight — and then you win the peace.”

The US-led coalition has carried out hundreds of strikes targeting ISIS in Syria in the last few weeks. Some were launched from neighboring Iraq, where the US has over 5,000 troops, according to CNN.

Hundreds of US troops also have been training locals in southern Syria, where Russia-backed pro-regime forces are seeking to kick out the Americans.

The US-led coalition this month denied any change to the US presence in Syria.

“Any reports indicating a change in the US position with respect” to the US military presence in Syria “is false and designed to sow confusion and chaos,” the coalition said in a statement.

Gen. Joseph Dunford, chairman of the Joint Chiefs of Staff, said this month the US needed to train thousands of local forces to ensure a lasting defeat of ISIS.

The timing of the withdrawal was not immediately clear and officials who spoke to Reuters on condition of anonymity did not reveal details about the deliberations. It was unclear how soon a decision could be announced.

A US withdrawal could open Trump up to criticism if ISIS re-emerges.

He has previously slammed his predecessor, Barack Obama, for the withdrawal of American forces from Iraq that preceded an unraveling of the Iraqi armed forces.

Iraqi forces collapsed in the face of ISIS’ advance into the country in 2014.

With Post wires