U.S. Defense Secretary Chuck Hagel, center, is seen aboard a U.S. Military Aircraft before speaking to members of the media during his flight, Sunday, June
U.S. Defense Secretary Chuck Hagel, center, is seen aboard a U.S. Military Aircraft before speaking to members of the media during his flight, Sunday, June 1, 2014. Hagel spoke about the released of U.S. Army Sgt. Bowe Bergdahl who was held hostage in Afghanistan, and who was handed over Saturday morning by members of the Taliban in exchange for five Afghan detainees held at the military prison in Guantanamo Bay prison in Cuba. (AP Photo/Pablo Martinez Monsivais, Pool)

U.S. commandos planned for the worst as they arrived at a site in eastern Afghanistan to free Army Sergeant Bowe Bergdahl after the Taliban had agreed to release him in exchange for five detainees held at Guantanamo Bay in Cuba, Defense Secretary Chuck Hagel said.

U.S. special operations forces took custody of Bergdahl at about 10.30 a.m. New York time on May 31 as the five Taliban detainees were handed over to Qatar authorities, who negotiated the exchange. Captured outside a U.S. base in Afghanistan, he was the only remaining American prisoner of war in the country.

"This is a very happy day for the Bergdahl family," Hagel told reporters Sunday on a military aircraft before arriving at the Bagram Airfield outside Kabul to meet with U.S. troops. "It's a very important day for our troops and our country."

Hagel's visit to Afghanistan is the first by a senior U.S. official since President Barack Obama announced May 27 that he planned to station 9,800 American troops in the country starting early next year if the next Afghan president signs a bilateral security agreement that has been stalled for months. Almost all U.S. troops would be withdrawn by the end of 2016.

What was billed as a routine troop visit for Hagel took on added significance as Bergdahl was released Saturday.

Although details of the swap had been agreed upon, the U.S. commandos arriving to take Bergdahl from the site along the border with Pakistan came prepared to fight, Hagel said.

"Where there's always danger, you prepare for all eventualities," Hagel said.

U.S. forces "took every possible precaution we could take, through intelligence, surveillance, reconnaissance, through having enough of our assets positioned in the right locations, having enough helicopters, and doing everything we could possibly do to anticipate violence, and anything going in a different direction," Hagel said.

Bergdahl was brought to the site by a group of as many as 18 Taliban fighters, a senior U.S. defense official told reporters Saturday. Bergdahl walked to the waiting U.S. helicopters and the operation was over quickly, according to the official, who asked not to be identified to discuss operations.

"No shots were fired, there was no violence," Hagel said of the operation. "It went as well as we not only had expected and planned, but also as well as it could have."

Hagel declined to provide more details on which commando units were involved or what types of helicopters were used.

"Some specifics are classified and will remain that way," he said.

Hagel stopped briefly at the Bagram base before heading to a NATO ministers' meeting in Brussels. He planned to meet U.S. military officials including Marine Corps General Joseph Dunford, commander of the International Security Assistance Force, as well as Ambassador James B. Cunningham. Hagel does not plan to meet Afghan President Hamid Karzai or any other Afghan officials.