President Barack Obama's national security adviser says Congress was well aware that the administration was considering trading Guantanamo Bay detainees for the only American prisoner of the Afghan War.

National Security Adviser Susan Rice said Sunday there were extensive consultations with lawmakers in Congress in the past and that they knew the idea of trading detainees was on the table.

Sgt. Bowe Bergdahl was freed Saturday after Obama agreed to release five high-level Afghan detainees from the U.S. prison in Cuba. He is believed to have been held by the Haqqani network since June 30, 2009.

Republican lawmakers have said that Obama violated U.S. law when he approved the exchange without notifying Congress 30 days in advance.

Rice made her comments on ABC's "This Week."

Nearly five years after his capture by insurgents, Sgt. Bowe Bergdahl's "safety and health were both in jeopardy" and officials had to act quickly to obtain his release, Defense Secretary Chuck Hagel said Sunday.

The only American prisoner of the Afghan war was freed Saturday after President Barack Obama agreed to release five high-level Afghan detainees from the U.S. prison at Guantanamo Bay, Cuba.

"While Bowe was gone, he was never forgotten," Obama said from the White House Rose Garden, where he was joined by Bergdahl's parents. "The United States of America does not ever leave our men and women in uniform behind."

Two Republican lawmakers, Rep. Howard "Buck" McKeon of California and Sen. James Inhofe of Oklahoma, said Obama violated U.S. law when he approved an exchange involving prisoners at Guantanamo without notifying Congress 30 days in advance.

In response, the White House said that officials considered what they called "unique and exigent circumstances" and decided to go ahead with the transfer in spite of the legal requirement.

And Hagel, who was traveling to Afghanistan to meet with U.S. troops, said the action was not relayed to Congress because of its urgency. He said intelligence indicated that Bergdahl's "health was deteriorating."

At Bagram Air Field, Hagel thanked the special operations forces that participated in the rescue. Gen. Joseph Dunford said there was a sense of excitement in the headquarters as the news spread

"You almost got choked up," he said. "It was pretty extraordinary. It has been almost five years and he is home."

Bergdahl's parents, Bob and Jani, led a tireless campaign to keep their son's story in the public eye. They were expected to hold a news conference Sunday in their hometown of Hailey, Idaho, where residents were planning a homecoming celebration for the soldier.

Bergdahl, in good condition and able to walk, was handed over to U.S. special operations forces by the Taliban in an area of eastern Afghanistan, near the Pakistani border, U.S. officials said. In a statement on its website, the Taliban put the location on the outskirts of Khost province.

The government of Qatar served as the go-between in the negotiations. Qatar is taking custody of the five Afghan detainees who were held at Guantanamo.

In weighing the swap, U.S. officials decided that it could help further the effort to reach reconciliation with the Taliban, something the U.S. sees as key to reaching a level of security in Afghanistan. But they acknowledged that there was a risk of emboldening other insurgent groups who might grab U.S. troops or citizens in an effort the secure the release of others prisoners.

Several dozen U.S. special operations forces, backed by multiple helicopters and surveillance aircraft, were involved in securing Bergdahl's transfer from about 18 Taliban members.

Bergdahl is believed to have been held by the Haqqani network since June 30, 2009. Haqqani operates in the Afghanistan-Pakistan border region and claims allegiance to the Afghan Taliban but operates with some degree of autonomy.

The U.S. believes Bergdahl was held for the bulk of his captivity in Pakistan, but officials said it was not clear when he was transported to eastern Afghanistan.

Officials said Bergdahl was taken to Bagram Air Field for medical evaluations, then transferred to Landstuhl Regional Medical Center, a military facility in Germany, before he's returned to the U.S. An official said Bergdhal was tentatively scheduled to go to the San Antonio Military Medical Center where he would be reunited with his family.

Bergdahl's parents had been in Washington on a previously planned visit when Obama called Saturday with news of their son's release.

As they stood with Obama in the Rose Garden, Bob Bergdahl said his son was having trouble speaking English after his rescue. The elder Bergdahl, who grew a long, thick beard to honor his son, had worked to learn Pashto, the language spoken by his son's captors, and delivered a message to him and the people of Afghanistan in that language.

Switching back to English, he said "the complicated nature of this recovery will never really be comprehended."

The circumstances surrounding Bergdahl's capture remain murky. There has been some speculation that he willingly walked away from his unit, raising the question of whether he could be charged with being absent without leave or desertion.

In 2012, Rolling Stone magazine quoted emails Bergdahl is said to have sent to his parents that suggest he was disillusioned with America's mission in Afghanistan, had lost faith in the U.S. Army and was considering desertion. Bergdahl told his parents he was "ashamed to even be American." The Associated Press could not independently authenticate the emails.

Hagel declined to say whether he believes Bergdahl was attempting to desert the Army or go AWOL when he walked away from his unit and disappeared.

"Our first priority is assuring his well-being and his health and getting him reunited with his family," Hagel said. "Other circumstances that may develop and questions - those will be dealt with later."

A senior U.S. official told The Associated Press that the Army would make the decision on any charges but that the feeling at the moment was that Bergdahl had suffered enough in his ordeal. All the officials who discussed details of Bergdahl's transfer insisted on anonymity because they were not authorized to be identified.

The U.S. has long sought Bergdahl's release, but there was renewed interest in his case as Obama finalized plans to pull nearly all American forces out of Afghanistan by the end of 2016.

Officials said the Taliban signaled to the U.S. in November that they were ready to start fresh talks on the issue of detainees. After the U.S. received proof that Bergdahl was still alive, indirect talks began, with Qatar sending messages back and forth between the two parties.

The five Guantanamo detainees departed the base on a U.S. military aircraft Saturday afternoon. Under the conditions of their release, they will be banned from traveling outside of Qatar for at least one year.

Obama and the emir of Qatar spoke last week about the conditions of the release, which have been codified in a memorandum of understanding between the two countries, officials said.

The detainees were among the most senior Afghans still held at the prison:

-Abdul Haq Wasiq, who served as the Taliban deputy minister of intelligence,

-Mullah Norullah Nori, a senior Taliban commander in the northern city of Mazar-e-Sharif when the Taliban fought U.S. forces in late 2001

-Khairullah Khairkhwa, who served in various Taliban positions including interior minister and had direct ties to Mullah Omar and Osama bin Laden

-Mohammed Nabi, who served as chief of security for the Taliban in Qalat, Afghanistan, and later worked as a radio operator for the Taliban's communications office in Kabul

-Mohammad Fazl, whom Human Rights Watch says could be prosecuted for war crimes for presiding over the mass killing of Shiite Muslims in Afghanistan in 2000 and 2001 as the Taliban sought to consolidate their control over the country.

In a statement on the Taliban website that was translated by the Washington-based SITE Intelligence Group, the Taliban said it "was and has been for a long time attempting to free all the imprisoned Afghan prisoners inside and outside the country, and restoring the right of freedom to them quickly."

The Taliban said it was seeking the release of additional prisoners but offered no specifics.

In Pakistan, Foreign Ministry spokeswoman Tasnim Aslam said her government was "not aware of" Bergdahl's release or the negotiations leading up to it. She declined to comment further.