WASHINGTON — President Trump has all the legal authority he needs to keep U.S. forces in Syria and Iraq indefinitely, the Pentagon and State Department said in a pair of letters released on Thursday. The letters also warned that the United States reserves the right to take military action to defend its anti-ISIS allies in Syria, potentially setting the stage for new clashes with regime forces and their Russian partners.

Sen. Tim Kaine, D-Va., to whom the letters were addressed, sharply criticized the administration’s reasoning and said in a statement that Trump risks “acting like a king by unilaterally starting a war.”

Borrowing arguments first advanced by the Obama administration, the Pentagon and State Department argued that the undeclared war on ISIS — and the presence of some 2,000 U.S. troops in Syria and 5,200 more in Iraq — is legal under the 2001 Authorization for Use of Military Force (AUMF) and the 2002 AUMF that set the stage for the invasion of Iraq. In late January, the Trump administration signaled that it would not seek a new vote to authorize the mission in Syria.

Like Obama, Trump contends that, because of its origins as an al-Qaida offshoot, the so-called Islamic State is covered by the 2001 legislation. The 2002 AUMF gave the president the power to use force to confront “the continuing threat posed by Iraq.”

“Now the Trump administration is going even further, claiming that the 2001 AUMF also allows the U.S. military to strike pro-Assad forces in areas devoid of ISIS to protect our Syrian partners who seek Assad’s overthrow,” Kaine said Thursday. “It is clear the Trump administration is crossing a constitutional line.”

While the U.S.-led coalition has routed ISIS and shattered its claims to a caliphate, the Pentagon said in its letter that the terrorist group has morphed into a dangerous “insurgency” and that U.S. forces need to remain in both countries to ensure its “permanent defeat.”

“Just as when we previously removed U.S. forces prematurely, the group will look to exploit any abatement in pressure to regenerate capabilities and reestablish local control of territory,” David Trachtenberg, the deputy undersecretary of defense for policy, wrote to Kaine.

“The United States does not seek to fight the Government of Syria or Iran or Iranian-supported groups in Iraq or Syria,” Assistant Secretary of State for Legislative Affairs Mary Waters said in her letter to Kaine. “However, the United States will not hesitate to use necessary and proportionate force to defend U.S., Coalition, or partner forces engaged in operations to defeat ISIS and degrade al-Qa’ida.”

The United States struck forces loyal to Syrian strongman Bashar Assad several times in 2017, notably striking an airfield in April in what Washington described as a response to the regime’s use of chemical weapons against civilians. More recently, a U.S. counterattack reportedly killed Syrian forces but also Russian mercenaries.

Kaine, who has tried for years to get his colleagues to debate and vote on authorizing the war against ISIS, warned in January that the U.S. mission in Syria was evolving and risked putting American forces on a collision course with regime troops and their Russian backers.

In remarks at Stanford University’s Hoover Institution, Tillerson said U.S. forces would stay in the war-racked nation to ensure ISIS does not reemerge, but also to set the stage for Assad’s removal from power through political means and to contain Iranian influence.

Iran has stepped up what America considers its destabilizing activities, including support for Assad and extremist groups, since the death of its archenemy Saddam Hussein and in the aftermath of the 2015 nuclear deal that Tehran signed with great powers including the United States. The Trump administration has vowed to confront the Islamic Republic more forcefully.