Eric Fanning testifies on Capitol Hill in Washington, D.C., Jan. 21, 2016. Alex Wong/Getty Images

he U.S. Senate unanimously backed President Barack Obama's nomination of Eric Fanning as secretary of the Army on Tuesday, making him the first openly gay leader of a U.S. military service branch.

Fanning previously worked as undersecretary of the Air Force and chief of staff to Defense Secretary Ash Carter.

He was confirmed by unanimous voice vote, eight months following his nomination, after Pentagon leaders assured Sen. Pat Roberts that it was now too late for the administration to transfer prisoners from the detention center at Guantanamo Bay, Cuba, to Roberts' home state, Kansas.

Roberts had held up Fanning's nomination for months to underscore his opposition to any possible transfer of detainees.

His opposition had frustrated his fellow Republican, John McCain, the chairman of the Senate Armed Services Committee, and strong supporter of Fanning's nomination.

On Tuesday, McCain and Roberts appeared in the Senate together as Roberts announced that he had released his "hold" on Fanning and spoken to Fanning.

McCain noted that this year's National Defense Authorization Act, or NDAA, ensures that the Obama administration does not have the authority to release or transfer detainees to the U.S. mainland.

Roberts said Deputy Defense Secretary Robert Work told him during a meeting last week that he would be unable to fulfill an order to move Guantanamo detainees to the United States before Obama leaves office in January 2017.

"The clock has run out for the president," Roberts said.