WASHINGTON — President Obama, apparently resigned to President Hamid Karzai’s refusal to sign a long-term security agreement with the United States before he leaves office, told him in a phone call on Tuesday that he had instructed the Pentagon to begin planning for a complete withdrawal of American troops from Afghanistan by the end of the year.

But in a message aimed less at Mr. Karzai than at whoever will replace him, Mr. Obama said that the United States was still open to leaving a limited military force behind in Afghanistan to conduct training and counterterrorism operations.

Noting that Mr. Karzai had “demonstrated that it is unlikely that he will sign” the agreement, Mr. Obama told him, in effect, that the United States would deal with the next Afghan leader. He warned Mr. Karzai that the longer it took for Afghanistan to sign the pact, known as a bilateral security agreement, or B.S.A., the smaller the residual force was likely to be.

It was the first time the leaders had spoken since last June, and for all intents and purposes, it marked the end of a relationship that had long since broken down in acrimony.