WASHINGTON — Defense Secretary Chuck Hagel acted illegally in May when he authorized the release of five Taliban detainees for Army Sgt. Bowe Bergdahl because he’d failed to provide lawmakers adequate notice of the exchange, the main investigative arm of Congress found Thursday.

Bergdahl, now 28, had been held for almost five years by his Taliban captors when he was freed May 31 in Afghanistan in exchange for five former Taliban officials who were released from the U.S. military detention center at Guantánamo Bay, Cuba, to the custody of the Qatar government.

Susan Poling, the top lawyer for the Government Accountability Office (GAO), said the prisoner swap violated two measures passed by Congress and signed by President Obama: a broad authorization bill for the Pentagon and the 2014 appropriations legislation funding its activities.

Poling’s opinion, which does not carry the force of law, revealed for the first time the price tag of the operation in which U.S. special-forces commandos whisked Bergdahl away after he was freed in eastern Afghanistan. The cost was $988,400.

Unlimited Digital Access. $1 for 4 weeks.

Poling concluded the Pentagon had spent the money illegally because it had failed to provide four Senate and four House committees at least 30 days’ notice of the Taliban prisoners’ release, as required by the defense-authorization bill. The panels were notified the day of the exchange.

Poling acknowledged, however, that she did not address deeper issues, involving the proper separation of powers between the legislative and executive branches. Those determinations were beyond the role of the GAO, she said.

The Obama administration declined to comment on Poling’s report.

Rear Adm. John Kirby, the Pentagon spokesman, said: “As Secretary Hagel testified to Congress, the recovery of Sgt. Bergdahl was conducted lawfully and in accordance with our responsibility to bring home a soldier taken captive in armed conflict. This is a judgment shared by the Justice Department.”

Obama and Hagel had said earlier that the president’s constitutional charge to protect the lives of U.S. service members and of all Americans abroad trumped the congressional requirement that he provide at least 30 days’ notice of the release of any terrorism detainees from Gitmo.

When he signed the National Defense Authorization Act last year, Obama issued a “signing statement” arguing that the 30-day notice requirement infringed on his constitutional authority as commander in chief.

The five freed Taliban, which include former senior officials from the government that ruled Afghanistan before the October 2001 U.S. invasion after the Sept. 11 terrorist attacks, must remain in Qatar for one year from their release under the terms of the deal.