WASHINGTON — The Senate on Tuesday confirmed Eric Fanning, the White House nominee to be the next secretary of the Army, making him the first openly gay man to hold an armed service's top civilian position.

Sen. Pat Roberts, R-Kan.sas, relinquished an eight-month hold he said was unrelated to Fanning’s qualifications or his sexuality. Roberts had sought  assurances from the Obama administration that detainees at the military’s Guantanamo Bay, Cuba, prison would not be relocated to Kansas, and he announced on the Senate floor Tuesday he had gotten received them.

The landmark move was praised by the Human Rights Campaign, the nation’s largest lesbian, gay, bisexual, and transgender civil rights organization. His nomination comes five years after the repeal of "Ddon’t aAsk, Ddon’t Ttell" legislation barring openly gay people from serving.

"Eric Fanning's historic confirmation today as Secretary of the U.S. Army is a demonstration of the continued progress towards fairness and equality in our nation's armed forces," HRC President Chad Griffin said in a statement. "Eric Fanning has spent his career serving this nation with tireless dedication, skill and ability, and as secretary he will bring that same commitment to the men and women of the U.S. Army."

Closing Guantanamo was a theme of President Obama’s 2008 campaign, and he has pushed to shutter the facility, transferring detainees overseas a few at a time. Congress had prohibited Obama from transferring detainees to US soil, yet the possibility prompted Roberts’ actions. 

On the Senate floor Tuesday, Roberts announced he had a private meeting with Deputy Defense Secretary Robert Work, who told him that he was the official "charged with executing any movement of detainees to the mainland, where he would be unable to fulfill such an order before the close of this administration."

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

There was also growing pressure on Roberts to release the hold, including items in the New York Times and Washington Post, which spotlighted Roberts' obstruction on Fanning, widely considered a highly qualified candidate, if not a historic pick. Senate Armed Services Chairman John McCain, whose committee advanced Fanning's nomination months ago, who said in April he had spoken with Roberts "ad nauseum" on the issue.

On Tuesday, McCain appeared beside Roberts and voiced his respect for the concerns of his "friend from Kansas," saying he and Roberts worked on this year's defense policy bill, which — if passed into law — would bar any administration request to reprogram funding to move detainees to the mainland. McCain also praised the US Army base Fort Leavenworth, home to a detention facility Roberts worried would house detainees, and the Army's general staff college.

Earlier in the day, Roberts had called Fanning to say he was lifting the hold and to wish him good luck on a speech to graduates of the US Military Academy at West Point. On the Senate floor, Roberts praised Fanning’s character and courage.

"He will be a tremendous leader as Army secretary and will do great by our soldiers at Fort Leavenworth and Fort Riley," he said, adding: "I look forward to voting for Mr Fanning, who has always had my support for this position."

Fanning was confirmed at around 5 p.m. by unanimous consent, meaning there was no opposition to force a roll call vote by the full Senate. Several lawmakers reacted with praise for Fanning on social media.

The move capped a long and tortured road in which Fanning, after President Obama nominated him in September of last year, hit an unusual number of roadblocks, considering his qualifications for the job. 

Fanning became Air Force undersecretary in April 2013,  served several months as acting secretary while the confirmation of now-Secretary Deborah Lee James was stuck in Congress, and was the Navy's deputy undersecretary of the Navy and its deputy chief management officer from 2009-2013. He also spent the first few months of 2015 as Secretary of Defense Ash Carter’s chief of staff.

He was named acting undersecretary of the Army in June of last year, in a move widely seen as laying the groundwork for him to replace the retiring Army Secretary John McHugh in November.

The challenges started shortly after his nomination was announced, when McCain stopped confirmations for key civilian DoD nominees to protest Democratic rule changes in the confirmation process and Obama's threat to veto the 2016 defense policy bill.

That hold ended in December, but another issue shortly cropped up. Following McHugh's retirement in November, the Pentagon announced Fanning would be acting secretary. However, senators took issue with that, and in January forced Fanning to suspend acting in that capacity. Army Undersecretary Patrick Murphy has been serving as the acting secretary since.

Military Times staff writer Jennifer-Leigh Oprihory contributed to this report.

Twitter: @AaronMehta | @ReporterJoe