WASHINGTON — The Senate confirmed Eric K. Fanning on Tuesday as secretary of the Army, making him the highest-ranking openly gay official ever at the Pentagon.

The voice vote ended a confirmation process that had been delayed for months by a Republican senator who wanted assurances that detainees from Guantánamo Bay, Cuba, would not be sent to his state.

But as the senator, Pat Roberts of Kansas, explained how his concerns had been resolved, one of his statements indicated that the administration does not believe it will be able to close the prison before President Obama leaves office.

Mr. Roberts said on the Senate floor that he had been assured last week by the deputy defense secretary, Robert O. Work, that Mr. Obama would not move Guantánamo detainees to Fort Leavenworth, Kan., because “the clock has run out.”