KABUL, Afghanistan 
Marine Gen. Joseph Dunford Jr., who was assigned to Camp Pendleton for many years, took charge of U.S. and NATO forces in Afghanistan on Sunday as the coalition enters its final stretch of the more than 11-year-old war.

The new commander faces daunting challenges, including making sure Afghan government forces are ready to take control and orchestrating the withdrawal of foreign forces during the next 23 months.

Dunford, who will likely be the last commander of the U.S.-led International Security Assistance Force, succeeded Marine Gen. John Allen, who oversaw the buildup of governmental security forces and dealt with a series of setbacks — from Korans burned at a U.S. base to a spike in deadly insider attacks that killed international troops.

“Today is not about change, it’s about continuity,” Dunford said during the handover ceremony at the coalition’s headquarters in Kabul. “What’s not changed is the growing capability of our Afghan partners, the Afghan national security forces. What’s not changed is our commitment. More importantly, what’s not changed is the inevitability of our success.”

The change in command comes at a critical time for President Barack Obama, who may use Tuesday’s State of the Union address to announce a timetable for pulling out the remaining American combat forces by the end of 2014 and plans for a residual U.S. force post-2014.

Dunford faces the challenge of overseeing the drawdown of about 100,000 foreign troops, including 66,000 from the United States, and helping the Afghans counter insurgent groups, including the Haqqani network, that show no sign of compromise. The Haqqani network, based in Pakistani tribal areas near the Afghan border, has ties to al-Qaida and is thought to be responsible for many attacks on U.S. and Afghan forces, including the recent spate of so-called insider attacks.

Dunford also must help Afghanistan secure its next presidential election in 2014 — the first ballot since the U.S. invasion that will not include President Hamid Karzai as a candidate.

“Much work lies ahead,” Gen. Martin Dempsey, chairman of the U.S. Joint Chiefs of Staff, said at the ceremony, which was attended by senior Afghan and U.S. military officials. Karzai did not attend.

Relations between the United States and Pakistan have greatly improved in recent months after a series of visits to Islamabad by Allen. Allen has worked to patch up ties after they hit historic lows following a border airstrike in late 2011 that killed two dozen Pakistani soldiers. Allen took Dunford along last week to Islamabad when he paid a farewell visit to the chief of the Pakistani army, Gen. Ashfaq Parvez Kayani.

Allen has been nominated to lead NATO forces in Europe after being exonerated in a Pentagon investigation of questionable email exchanges with a Florida woman linked to the sex scandal that led CIA Director David Petraeus to resign.

Allen, 59, was the longest serving commander of U.S. and coalition troops in Afghanistan so far. Nearly two dozen generals have commanded troops from the United States and other nations in the coalition since the American invasion in late 2001 — with six U.S. generals, including Dunford, running both commands in the past five years alone.

Dunford grew up in Boston and was commissioned as a Marine officer in 1977. Among the many roles Dunford has performed in his long career was as commander of Camp Pendleton’s 1st Marine Expeditionary Force until 2010. The four-star general’s most recent position was as assistant commandant of the Marine Corps.

Allen said he told Dunford “our victory here will never be marked by a parade or a point in time on a calendar when victory is declared. This insurgency will be defeated over time by the legitimate and well-trained Afghan forces that are emerging today and who are taking the field in full force this spring.”

Allen, however, has acknowledged that the Afghans still have work to do to become an effective and self-sufficient fighting force. But he said a vast improvement in their abilities was behind a decision to accelerate the timetable for putting them in the lead nationwide this spring when the traditional fighting season begins.

Although the Afghan security forces are almost at their full strength of 352,000, persistent violence and insider attacks against Americans and other foreign forces have raised concerns about whether they are ready to take on the fight by themselves.

Dunford has to deal with “navigating the drawdown, keeping a sense of calm before (Afghan) presidential elections” and maintaining progress against insider attacks, said Michael O’Hanlon from the Brookings Institution in Washington. “Then, of course, there’s the issue of gradually working more closely with Pakistan.”

Much depends on the U.S. negotiating a bilateral security agreement with the Afghan government that includes the contentious issue of immunity from Afghan prosecution for any U.S. forces that would remain in Afghanistan after 2014. Karzai has said he will put any such decision in the hands of a council of Afghan elders, known as a Loya Jirga.

Although Dempsey said recently that the United States had plans to leave a residual force, a failure to strike a deal on immunity would torpedo any security agreement and lead to a complete pullout of U.S. forces after 2014 — as it did in postwar Iraq. It is widely believed that no NATO-member nation would allow its troops to remain after 2014 to train, or engage in counterterrorism activities, without a similar deal.