WARSAW, Poland -- President Barack Obama on Tuesday defended his decision to release five Afghan detainees from Guantanamo Bay in exchange for an American soldier's freedom, saying his administration had consulted with Congress "for some time" about that possibility. The chairman of the Joint Chiefs of Staff left open the possibility of desertion charges against the soldier.

Gen. Martin Dempsey noted that U.S. military leaders have been accused of "looking away from misconduct" and said "it's premature" to assume they would do so in the case of Sgt. Bowe Bergdahl, despite his five years as a Taliban detainee.

Dempsey, in an Associated Press interview, said the Army may still pursue an investigation that could lead to desertion charges against Bergdahl, who was captured by insurgents in Afghanistan after he apparently walked away from his base in 2009.

Obama, meanwhile, brushed aside questions about the circumstances surrounding Bergdahl's capture. He said the United States has a "sacred" obligation to not leave men and women in uniform behind.

"Regardless of the circumstances, whatever those circumstances may turn out to be, we still get an American soldier back if he's held in captivity," Obama said during a news conference in Poland as he opened a three-country European visit. "We don't condition that."

There have long been questions about how Bergdahl disappeared from his unit. The Pentagon concluded in 2010 that Bergdahl walked away, and the military curbed any high-risk rescue plans after an initial flurry of searching.

Despite the Pentagon's conclusions, Obama said the government was not currently seeking to punish Bergdahl as a deserter.

"Our main priority is making sure the transition that he's undergoing after five years in captivity is successful," he said.

Days after his rescue, Bergdahl, 28, of Hailey, Idaho, was in stable condition at a U.S. military hospital in Germany. He is yet to be reunited with his parents, Bob and Jani Bergdahl, also of Hailey, Idaho, who waged a tireless campaign to keep their son's story in the spotlight.

Questions were also mounting in the U.S. over the way Bergdahl's freedom was secured: Five high-level members of the Taliban were released from the U.S. prison in Guantanamo Bay, Cuba, and sent to Qatar. The five, who will have to stay in Qatar for a year before going back to Afghanistan, include former ministers in the Taliban government, commanders and one man who had direct ties to the late al-Qaida chief Osama bin Laden.

Republicans in Congress criticized the agreement and complained about not having been consulted, citing a law that requires that Congress be notified 30 days before a prisoner is released from Guantanamo. Republicans on the House Armed Services Committee said the Pentagon notified the panel by phone on Saturday that the exchange was occurring in the next five hours.

Obama suggested that lawmakers were aware of the prospect that the U.S. could agree to a prisoner swap with the Taliban. And he defended his administration's handling of the formal notifications, saying that when the opportunity to free Bergdahl presented itself, "We seized that opportunity."

Officials said delaying Bergdahl's transfer in order to comply with the congressional notification rules would have interfered with two of the president's constitutional authorities: protecting the lives of Americans abroad and protecting U.S. soldiers.

"Because such interference would significantly alter the balance between Congress and the president, and could even raise constitutional concerns, we believe it is fair to conclude that Congress did not intend that the administration would be barred from taking the action it did in these circumstances," White House spokeswoman Caitlin Hayden said in a statement released shortly after Obama's news conference.

Obama has previously expressed concern about the congressional notification requirement, which was passed as part of the 2014 defence bill. In a statement that accompanied his signing of that legislation, Obama said the executive branch must have flexibility "to act swiftly in conducting negotiations with foreign countries regarding the circumstances of detainee transfers."

The U.S. and the Taliban negotiated the prisoner exchange indirectly, with the government of Qatar serving as an intermediary. The U.S. and Qatar signed a memorandum of understanding governing the conditions of their release, though the exact stipulations beyond the travel ban are unknown.

Obama acknowledged that there is always a chance that the released Afghans could rejoin the Taliban or other groups seeking to harm the U.S. But he warned that the U.S. will be closely tracking their activity.

"We will be keeping eyes on them," Obama said. "We have confidence that we will be in a position to go after them if in fact they are engaging in activities that threaten our defences."

Associated Press writer Lolita C. Baldor in Brussels contributed to this report.