Secretary of Defense Chuck Hagel testified Wednesday about the prisoner exchange last month that swapped Taliban detainees for Sgt. Bowe Bergdahl, the only U.S. soldier still held captive in Afghanistan. 

Hagel told the House Armed Services Committee that the swap was the "last, best" chance to release Bergdahl, and said mediators told him that time was running out to ensure Bergdahl's release, The Associated Press reports. 

Hagel said that Qatari officials warned that a leak could sabotage the deal if they waited any longer. He said that the transfer of the five detainees from Guantanamo Bay, Cuba to Qatar was in the nation's best interest. 

However, Republicans and a handful of Democrats criticized the Obama administration for not telling Congress about the exchange in advance, and some accused President Obama of breaking a law that requires 30 days of notification for the release of Guantanamo prisoners. Lawmakers also questioned whether Bergdahl deserted the military, and whether the swap was worth it, as administration officials said four of the five Taliban members will most likely continue to fight with the Taliban. 

"We could have done a better job of keeping you informed," Hagel said, but called the operation an "extraordinary situation" involving time constraints and concerns over Bergdahl's safety. 

"We grew increasingly concerned that any delay, or any leaks, could derail the deal and further endanger Sgt. Bergdahl," Hagel said. "We were told by the Qataris that a leak would end the negotiations for Bergdahl's release. We also knew that he would be extremely vulnerable during any movement, and our military personnel conducting the hand-off would be exposed to a possible ambush or other deadly scenarios in very dangerous territory."'

Rep. Howard "Buck" McKeon, R-Calif., the committee's chairman, said the agreement with the Taliban was "deeply troubling," and called it negotiations with terrorists, according to The Associated Press

McKeon said the deal could increase American military kidnappings, and went so far as to call the administration's explanations of the events as "misleading and oftentimes blatantly false."

Hagel retorted by stating that the Taliban officials were not implicated in terrorist attacks against the U.S., and that Qatar committed to security measures and promised to keep the Taliban members in the country for a year. 

Hagel also denied having direct talks with the Taliban personnel, saying they engaged in "indirect negotiations."

He said the agreement was arranged May 27, and Obama gave the go-ahead for the exchange four days before. He said officials learned of the location of the exchange an hour before it took place. 

Hagel also said the administration spoke with the Justice Department about whether it was necessary to tell Congress about the plan, and the department said it was not necessary. 

Rep. Jeff Miller, R-Fla., said he did not understand why Bergdahl was receiving medical treatment in Germany. 

"You're telling me he is being held in Landstuhl, Germany because of his medical condition?" Miller asked. 

"Congressman, I hope you're not implying anything other than that," Hagel responded. "This guy was held for almost five years in God-knows-what kind of condition," he added. 

Bergdahl, a soldier from Idaho, was captured in 2009. 

The House Appropriations Committee also prohibited money from being appropriated for the transfer of a Guantanamo detainee, demonstrating their discontent with the situation. The committee is also withholding money from the Defense Department until Hagel proves that the rules of adequate notification will be followed in the future.