Ryan C. Crocker, one of the most accomplished U.S. diplomats, took the oath of office Monday as ambassador to Afghanistan, telling the diplomatic community here that the United States will not “rush for the exits” in the country’s longest declared war.

Crocker, who helped reopen the U.S. Embassy in Kabul in 2002 before serving as ambassador to Iraq, is no stranger to war zones. But his new position could be his most challenging.

He is charged with overseeing the world’s largest diplomatic mission just as American and other foreign troops begin to leave the country.

“It’s time for us to step back and for the Afghans to step forward,” he said.

Crocker replaces Karl W. Eikenberry, whose tenure in Kabul was punctuated by spats with Afghan President Hamid Karzai and tension with Washington over the military surge announced in 2009.

Crocker inherits a diplomatic mission that grew under Eikenberry from 200 people in 2008 to more than 1,100 in 2011: the face of a civilian surge intended to bolster governance and development in Afghanistan.

Though Crocker said Monday that progress has been made, he added that “we must proceed carefully. . . . Frankly, we left the wrong way in the 1990s, and we all know the consequences of those decisions.”