US Army soldiers walk on the side of a hill during a patrol near Baraki Barak base in Logar Province, on Oct. 10, 2012. (MUNIR UZ ZAMAN/AFP/GETTY IMAGES)

President Obama’s pick to be the next commander of U.S. and NATO troops in Afghanistan said Thursday that he foresees maintaining American forces and equipment in the country after international contingents leave by the end of 2014.

But Marine Gen. Joseph Dunford made clear that his job will be to close down an unpopular war that is in its 12th year. Under tough questioning from Republicans at his Senate confirmation hearing, Dunford stuck closely to the plan to wind down the war on Obama’s schedule.

“With continued focus and commitment, I believe our goals are achievable,” Dunford said.

Republicans have argued that, by setting an iron-clad deadline for leaving, Obama encouraged the Taliban, its backers in Pakistan and the Afghan government to hedge their bets now and jockey for influence later. In his failed presidential bid, Mitt Romney suggested he would revisit the exit plan.

Dunford, the second-ranking Marine at the Pentagon, is expected to win quick confirmation this month to succeed Marine Gen. John R. Allen as the top general in Afghanistan. Over the next two years, Dunford would oversee the scaling down of the 68,000 U.S. forces in Afghanistan and the handoff to Afghans of primary responsibility for fighting the Taliban and the remnants of al-Qaeda.

The plan set by Obama, NATO allies and Afghan President Hamid Karzai calls for handing over primary responsibility for combat and security to Afghan forces next year and removing all American and other foreign combat troops by the end of 2014. Both goals are reasonable, Dunford told the Senate Armed Services Committee.

Dunford ducked questions from Democrats and Republicans about whether he wants to draw down forces gradually, as the White House prefers, or in a sudden exit near the deadline.

Allen is due to present drawdown recommendations to the White House before the end of the year.

Dunford endorsed the idea that the United States should keep some troops in the country past 2014 in what he called an advisory role. He also said there will be a continuing need for counterterrorism operations in Afghanistan to stop any rejuvenation of al-Qaeda or other groups that might threaten the United States and its allies.

He refused to say how many forces he envisions, but he said 1,000 would be too few. The troops will need American air power such as combat helicopters to be effective, Dunford added.

The general stressed the need to avoid waiting too long to start negotiations over what sort of force the Americans will leave in Afghanistan. He said the talks started too late in Iraq, where the government rejected the idea of a residual U.S. force.

U.S. and Afghan negotiators met for the first time Thursday to begin work on a security agreement that would govern U.S. forces after 2014.

Sen. Lindsey O. Graham (R-S.C.) warned Dunford that he wouldn’t vote for “a penny” for the war if that deal does not give U.S. soldiers full immunity from any prosecution in Afghan courts, one of the sticking points in Iraq.

The hearing was supposed to be a double-billing for Dunford and Allen, who has been nominated for a new job as supreme allied commander in Europe. Obama asked that Allen’s confirmation be delayed pending the outcome of a Pentagon inquiry into e-mail communications between the general and a Tampa woman. Allen’s military lawyer said he is cooperating with the investigation by the Pentagon’s inspector general.

Senate Armed Services Committee Chairman Carl Levin (D-Mich.) and other senators voiced support for Allen. But the only mention at the hearing of Allen’s far-better-known predecessor as Afghan commander, David H. Petraeus, came in passing. Petraeus, a retired four-star general, resigned last Friday as director of the CIA after acknowledging an extramarital affair.