BEIRUT, Lebanon — The commander of the American-backed militia in Syria said Tuesday that it would attack Turkish forces if they entered northeastern Syria, while Turkey’s president, Recep Tayyip Erdogan, indicated that such an operation was imminent.

“We will resist,” Mazlum Kobani, commander of the Kurdish-led militia, said in an interview with The New York Times. “We have been at war for seven years, so we can continue the war for seven more years.”

Mr. Erdogan, speaking to reporters on a flight to Serbia, said the operation might happen before the news could be printed. Turkish troops were being bused to the Syrian border in preparation for an incursion, Turkish media reported. And the Turkish Defense Ministry said on Twitter that preparations to enter Syria “had been completed.”

The escalating challenge came after President Trump agreed to let the Turkish operation go forward and to move American troops out of the way. On Monday, American troops withdrew from posts near two Syrian towns near the border.