It's only a slight stretch to say America's longest war stops here.

The several hundred American soldiers on this remote base in Afghanistan's wild east are the vanguard of a transformed U.S. military mission meant to avoid the kind of unraveling of security that happened this year in Iraq and ensure that the reason for invading Afghanistan in the first place — Al Qaeda's haven for plotting the Sept. 11 attacks — never recurs.

These soldiers, including elements of the 3rd Infantry Division and the 3rd Cavalry Regiment, are not fighting the Taliban. They are trying to script the final chapter of the U.S. part in a conflict that seems certain to continue after the Americans leave.

Gamberi, a dusty outpost in Laghman province near the fabled city of Jalalabad, will be one of four "Train, Advise, Assist Commands" across the country, in addition to several training establishments in Kabul, the capital.

Gone are the days of large U.S. combat forces here or in any other part of Afghanistan, although U.S. special operations forces will continue, mostly in conjunction with Afghan forces, to hunt down Al Qaeda remnants or other terrorists.

U.S. troops also will take on the Taliban in situations where they are deemed to pose a threat to American troop security.

The largest mission, however, is going to be training the Afghans — not on the front lines but at bases such as Gamberi.

U.S. Defense Secretary Chuck Hagel dropped in Sunday to get briefed on their work and to deliver a holiday-season pep talk.

Before a few hundred soldiers, Hagel said the idea is to "work our way, essentially, out of a job as we transition from the combat role we've had over the last 13 years" to a mission that puts the onus on Afghan combat prowess.

He said the Afghan army and police forces have made a lot of progress, at the cost of much U.S. blood and treasure since 2001.

"We don't want to see that roll back downhill," Hagel said.

Gamberi exemplifies what President Barack Obama calls the new noncombat mission.

The soldiers here are focused on training and advising Afghan security forces; it's a mission with NATO allies that will assume a new name on Jan. 1, "Resolute Support." The long combat mission known as Operation Enduring Freedom will conclude at the end of December.

This new phase will not last long, however, if current plans hold.

Virtually all U.S. troops will be gone two years from now as Obama completes his final term in office. The hope is that the Afghans can hold off Taliban militants who, it is feared, could allow a return of Al Qaeda or other extremist groups if they were to regain power in Kabul.

Gen. John Campbell, the top American commander in Afghanistan, said Saturday that he has Obama's permission to keep up to 10,800 U.S. troops in the country for the first few months of 2015; that's about 1,000 more than previously planned.

As a result, there will be little, if any, net drop in U.S. troop numbers between now and Dec. 31. By the end of 2015, however, the U.S. troop total is to shrink to 5,500, and to near zero by the end of 2016.

In an interview, Campbell said the Afghans are not only capable of providing their own security but are eager to do so.

"They totally have the security. They want to own it. They are proud that they have that back" as a sovereign nation, he said.

Campbell said part of his challenge is to build confidence among Afghan troops, partly by reminding them that their firepower is superior to that of the Taliban. He also is pushing them to be more aggressive and take the fight to the Taliban.

"They have this checkpoint mentality" that makes them prefer to wait at fixed positions for the Taliban to come to them. "I'm trying to get them off that" approach, he said. "They've got to become more maneuverable to get out there and go after the enemy."

Hagel, on what aides said was surely his last visit to Afghanistan as defense secretary, told U.S. troops that there is no room for complacency and no reason to think that their training and advising work will not present its own risks.

"The job's not done," he said. "This is still a dangerous country in many ways."