By Jessica Donati and Mark Felsenthal

KABUL/WASHINGTON (Reuters) - Afghanistan's President Hamid Karzai has refused to sign a security deal with the United States, the White House said, opening up the prospect of a complete withdrawal of U.S. troops from the strife-torn nation next year.

Karzai told U.S. National Security Advisor Susan Rice in Kabul on Monday that the United States must put an immediate end to military raids on Afghan homes and demonstrate its commitment to peace talks before he would sign a bilateral security pact, Karzai's spokesman said.

The White House said Karzai had outlined new conditions in the meeting with Rice and "indicated he is not prepared to sign the promptly".

"Without a prompt signature, the U.S. would have no choice but to initiate planning for a post-2014 future in which there would be no U.S. or NATO troop presence in Afghanistan," a White House statement quoted Rice as saying.

The complete withdrawal, called the "zero option", would be similar to the pull-out of U.S. troops from Iraq two years ago.

On Sunday, an assembly of Afghan elders, known as the Loya Jirga, endorsed the security pact, but Karzai suggested he might not sign it until after national elections next spring.

The impasse strengthens questions about whether any U.S. and NATO troops will remain after the end of next year in Afghanistan, which faces a still-potent insurgency waged by Taliban militants and is still training its own military.

Karzai's defiance has surprised the many who had attended the Loya Jirga, which he had proclaimed would have the final word on the security deal.

A senior politician in Kabul said it appeared that Karzai's reluctance to let the deal go through stemmed from his eagerness to keep his hands on the levers of power in the run-up to a presidential election in April, when he is due to stand down.

"He is now in confrontation with his own nation as well as the United States," said the politician, who asked not to be named.

Story continues

He added that the president's demand for no U.S. meddling in the coming election suggested that Karzai could be looking to ensure he has room to influence the outcome himself.

RESIDUAL FORCE

U.S. and other foreign troops have been in Afghanistan since the ousting of the Taliban regime by U.S.-backed Afghan forces in late 2001.

Just over two years ago, U.S. President Barack Obama pulled the plug on talks with Iraq about keeping a residual American force there after that war. In October 2011, when he announced that decision, there were more than 40,000 troops in the country. By the end of the year, they had all been withdrawn.

In Afghanistan, there are still 47,000 American forces. The United States has been in discussions with Afghan officials about keeping a small residual force of about 8,000 troops there after it winds down operations next year.

U.S. officials, including Secretary of State John Kerry and Defense Secretary Chuck Hagel, have said the bilateral security deal with Afghanistan must be signed by year-end to begin preparations for a post-2014 presence.

Rice, who made a three-day visit to Afghanistan to visit U.S. troops, told Karzai it was "not viable" to defer signing the deal until after the election, the White House said.

The delay "would not provide the United States and NATO allies the clarity necessary to plan for a potential post-2014 military presence", the White House said.

CONDITIONS

Karzai spokesman Aimal Faizi said the Afghan leader laid out several conditions for his signature to the deal in the meeting, including a U.S. pledge to immediately halt all military raids on, or searches of, Afghan homes.

The Bilateral Security Agreement (BSA) includes a provision allowing raids in exceptional circumstances - when an American life is directly under threat - but it would not take effect until 2015.

This issue is particularly sensitive among Afghans after a dozen years of war between Afghan and foreign forces and Taliban militants.

"It is vitally important that there is no more killing of Afghan civilians by U.S. forces and Afghans want to see this practically," Faizi said.

Karzai also called on Washington to send remaining Afghan detainees at the U.S. military detention center in Guantanamo Bay, Cuba, back to Afghanistan, saying that the Loya Jirga had endorsed the pact with this condition.

Faizi said Karzai also asked the U.S. officials to guarantee that the United States would refrain from endorsing any candidate in next year's election.

Karzai blamed the United States for meddling in the 2009 presidential election, while his opponents accuse the president of using the pact to ensure his influence in next year's polls.

U.S. officials have appeared exasperated by Karzai's stance on the security agreement, which they say is needed to help them plan a future mission that will assist Afghan forces fight militants and that will allow for future aid crucial for the impoverished nation.

The Obama administration has not said when it would make a decision to abandon the talks and commit to pulling all of its troops out of Afghanistan at the end of 2014, as it did in Iraq.

Faizi said the Afghan president had asked his American visitors to return to the U.S. president with his message.

"The ball is in your court now, and get back to us," he said.

(Editing by Missy Ryan, Raju Gopalakrishnan and Alex Richardson)