WASHINGTON – Defense Secretary Chuck Hagel delivered an aggressive defense Wednesday of the secret prisoner exchange of five Taliban detainees for a U.S. soldier, telling Congress that the risks were too great and the situation too uncertain for the administration to tell lawmakers about the plan.

In a nearly five-hour Capitol Hill hearing that was at times contentious, House members accused Hagel and the White House of not trusting them enough to follow the law and fill them in on the decision to exchange Sgt. Bowe Bergdahl for five detainees at the U.S. facility at Guantanamo Bay, Cuba.

An equally combative Hagel said the deal provided “the best possibility that we had to get him out, and we were concerned we might lose it.” He said officials discussed the law requiring that Congress get a 30-day notice of detainee exchanges but said the Justice Department told them that in such extreme circumstances President Barack Obama had the constitutional authority to forgo the notice.

The Justice Department declined to comment on advice it gave the White House.

The first Obama administration official to testify about the prisoner swap, Hagel acknowledged up front that the matter could have been handled better. But he offered no apology for keeping Congress in the dark, insisting that Qatari officials negotiating the swap between the U.S. and the Taliban made it clear that “time was not on our side.”

U.S. officials said last week that intelligence suggested that the captors might have killed Bergdahl if word of the swap leaked out.

Calling the operation an “extraordinary situation,” Hagel said there were concerns about Bergdahl’s health and safety, the last-minute arrangements over where to pick up the soldier and persistent fears the Taliban may have been negotiating in bad faith. He said the deal only came together in the final 96 hours, and that the commandos sent to retrieve Bergdahl only knew the exact location an hour before the exchange.

“As the opportunity to obtain Sgt. Bergdahl’s release became clear, we grew increasingly concerned that any delay or any leaks could derail a deal and further endanger Sergeant Bergdahl,” Hagel told the House Armed Services Committee. “We were told by the Qataris that a leak, any kind of leak, would end the negotiation for Bergdahl’s release.”

Republicans and Democrats questioned the wisdom of releasing the five Taliban members, saying they could return to the battlefield. Administration officials have told Congress that four of the five Taliban officials will likely rejoin the fight.

Opening the hearing, Rep. Howard “Buck” McKeon, R-Calif., the committee’s chairman, described the agreement with the Taliban as the “deeply troubling” result of “unprecedented negotiations with terrorists.”

McKeon, who has launched a committee investigation, said the deal could spark kidnappings of American personnel. And he described White House explanations thus far about the potential national security implications as “misleading and oftentimes blatantly false.”

Hagel called the former Taliban government officials “enemy belligerents” but said they hadn’t been implicated in any attacks against the United States. He said Qatar, which has promised to keep the former Guantanamo detainees inside the country for a year, committed to sufficient security measures that led him to decide the risks weren’t too great. He said details of those assurances are classified, but were being provided to the lawmakers.

At the same time, Hagel said, “if any of these detainees ever try to rejoin the fight, they would be doing so at their own peril.”

Hagel, who received two Purple Hearts for his Army service in Vietnam, faced sometimes scathing criticism, provided a sharp contrast to what many had described as a lackluster showing at his nomination hearing last year. He was most animated when one lawmaker questioned why Bergdahl was still in a hospital in Germany and not in the U.S. for questioning.

“We have seriously wounded soldiers that are returned to the United States immediately after they are stabilized,” said Rep. Jeff Miller, R-Fla. “You’re telling me he is being held in Landstuhl, Germany, because of his medical condition?”

“Congressman, I hope you’re not implying anything other than that,” Hagel snapped back, his voice rising as each tried to speak over the other. “He’s being held there because our medical professionals don’t believe he’s ready. ... This isn’t just about a physical situation, congressman. This guy was held for almost five years in God knows what kind of conditions. ... This is not just about can he get on his feet and walk and get to a plane.”

Lawmakers also noted that the administration had told lawmakers about the secretive military operation to go after Osama bin Laden, and questioned why this was different.

“It’s not just about somebody having their feelings hurt,” said Rep. Mac Thornberry, R-Texas. “This decision undermines a lot of the working relationship in all these areas of national security. And I think it’s important that the whole administration understands some of the ramifications of this.”

Hagel, however, contended that in some ways the prisoner exchange was more risky because the U.S. had less control over the plan, largely because many of the details of the exchange came out only in the final days and hours.

Hagel said Washington only engaged in “indirect negotiations.” He said a logistical agreement was released May 27, four days before the exchange, and only then did Obama make a final decision to move forward.

Bergdahl, an Idaho native, was taken captive in 2009. The Taliban detainees had been at Guantanamo for more than a decade.