“I’ll be meeting personally with Taliban leaders in the not-too-distant future and will be very much hoping that they will be doing what they say they’re going to be doing,” the president said at a news conference in Washington hours after the agreement was signed. “They will be killing terrorists. They will be killing some very bad people, they will keep that fight going.”

He went on: “As you know, we destroyed in Syria and Iraq 100 percent of the ISIS Caliphate, 100 percent. We have thousands of prisoners. We’ve killed ISIS fighters by the thousands, and likewise in Afghanistan, but now it’s time for somebody else to do that work and that’ll be the Taliban. And it could be surrounding countries. There are many countries that surround Afghanistan that can help.”

“I really believe the Taliban wants to do something to show that we’re not all wasting time,” he added. “If bad things happen, we’ll go back. I let the people know we’ll go back, and we’ll go back so fast and we’ll go back with a force like nobody’s ever seen.”

At the CPAC conference in Maryland on Saturday afternoon — a gathering of thousands of conservatives wholly devoted to the president — Mr. Trump picked up his theme of the Taliban as a potential ally.

“I’ll say this for the Taliban,” he said. “They’re great fighters. You know that obviously. They’re great fighters. All you have to do is ask the Soviet Union. Are they great fighters? They are great fighters. But they’re tired also. This is 19 years, 19 years.”