State Department Special Representative for Afghanistan and Pakistan James Dobbins testifies during a Tuesday hearing. (Alex Wong/Getty Images)

The Obama administration believes it can still finalize a security agreement with Afghanistan to keep a U.S. military presence in the country after 2014, despite threats by President Hamid Karzai to walk away from the deal, the U.S. special representative to Afghanistan said Tuesday.

But Ambassador James F. Dobbins also warned that delays in signing the proposed deal could further undermine stability in the country as it prepares to assume full control of its security for the first time since the arrival of U.S. troops in 2001.

Dobbins, in testimony before the Senate Foreign Relations Committee, appeared to back away from earlier suggestions that all U.S. forces would be pulled out of Afghanistan next year unless the bilateral security agreement is signed by the end of the month. The White House has expressed exasperation at the behavior of Karzai, who assented to the deal but now says he may not sign it until after Afghanistan’s presidential election in April.

“I have no doubt that the BSA, ultimately, will be concluded,” Dobbins told the Senate panel. He said that there was “some prospect” that the agreement might still not be signed this year but that the Obama administration would not simply walk away from its commitment to Afghanistan.

“We are nowhere near a decision that would involve our departing Afghanistan altogether,” he said.

The dispute with Karzai is over a long-term military arrangement that would allow a small number of U.S. forces to remain in Afghanistan in training and advisory roles after the last combat troops depart late next year. The agreement has won broad support from a grand council of Afghan elders and leaders, called the loya jirga, as well as senior members of Karzai’s cabinet.

But Karzai appeared to put the deal at risk by adding last-minute conditions, including a promise by the United States never to allow its forces to conduct counter­terrorism raids on Afghan homes, even if Afghan troops were leading the mission. He also insisted that U.S. officials free Afghan prisoners held at Guantanamo Bay, Cuba, and set up a high-level peace council that included members of the Taliban. The Taliban has refused to engage in talks with the Karzai government.

The always-volatile U.S. relationship with Karzai has become increasingly strained in recent weeks, so much so that Defense Secretary Chuck Hagel didn’t meet with the Afghan president during a visit to Kabul last week.

Dobbins, in his testimony, appeared to allow for the possibility that the formal signing of the security agreement might have to wait until after the Afghan election, though he said such a delay would “impose large and unnecessary costs on the Afghan people.”

“Already, the anxiety caused by President Karzai’s refusal to heed the advice of the loya jirga is having such an effect,” Dobbins said.

The testimony came hours after a French newspaper published an interview in which Karzai blasted the United States for its conduct in the dispute over the security agreement.

Karzai told Le Monde that Washington was behaving like a colonial power, threatening to deny Afghanistan billions of dollars in allocated aid if he did not sign off on the deal.

“ ‘We won’t pay salaries, we’ll drive you into a civil war.’ These are threats,” Karzai said.

Lawmakers at Tuesday’s hearing accused Karzai of irrational behavior and said he was “testing our patience,” in the words of Sen. Robert Menendez (D-N.J.), the Foreign Relations Committee chairman.

“I believe this brinksmanship is unwarranted and, frankly, insulting to the sacrifices made by the United States military and taxpayers, and it is not in Afghanistan’s best interest,” Menendez said.