Defense Secretary Ashton B. Carter is under pressure to close the military prison at Guantanamo Bay, Cuba, seen here in 2014, by the time President Obama leaves office. (Ben Fox/AP)

Defense Secretary Ashton B. Carter will face a crucial test in the coming months over the prison at Guantanamo Bay, Cuba, as pressure mounts on the Pentagon to resettle detainees overseas and help President Obama make good on one of his top national security goals.

Administration officials have been scrambling for months to devise a viable plan for shuttering the controversial military prison, a goal that Obama announced on his first day in office but that has been stalled for years by opposition in Congress and, internally, slowed by resistance at the Pentagon.

Frustrated by the lack of progress, Obama and Secretary of State John F. Kerry have pressed Carter since he took over earlier this year to ensure that detainee resettlement occurs quickly.

In late August, Carter and Obama met at the White House to discuss, among other issues, the effort to close Guantanamo by the time the president leaves office in 2017. At that meeting, Carter assured Obama that he was taking steps to break a bottleneck in the Pentagon’s process and was working through most of the backlog of detainee transfers.

Carter told the president that he had “cleared the deck,” meaning he had signed off on resettling all the detainees whose papers had reached his desk, the last step in a byzantine process across multiple agencies, according to one of several U.S. officials who spoke on the condition of anonymity to discuss internal discussions.

But most of those 12 transfers had been arranged months or even years earlier under previous secretaries. And there are still 114 detainees at the prison, a number the White House wants to bring well below 100 by the end of the year — a goal that will require the Pentagon to substantially accelerate the pace of detainee resettlement.

Many officials are skeptical that a process that has been choked by bureaucratic infighting can be easily fixed. Particularly hard to overcome, they say, is the enduring reluctance of some military officials to free prisoners who they fear might take up arms against U.S. troops in the future.

“There have been a lot of squandered opportunities,” said a senior U.S. official, who added that Carter needs to show he’s serious about closing the prison. “The clock is not our friend.”

Shutting down Guantanamo — with its history of hunger strikes, harsh treatment and opaque military court proceedings — was supposed to illustrate Obama’s break with the practices of President George W. Bush and the darkest aspects of the government’s response to the 9/11 attacks. Instead, Obama’s failure to overcome opposition to the prison’s closure threatens to symbolize the unfulfilled ambitions of his presidency.

Now, Carter is vowing to make the closing of the notorious prison a higher priority at the Pentagon, where the process has been slowed by concerns about releasing dangerous detainees.

The stakes are high for Carter, an experienced bureaucrat and former academic who replaced Chuck Hagel in February. Hagel’s reluctance to authorize detainee transfers created friction with the White House and contributed to his early resignation.

Officials at the Pentagon said the professorial Carter, who appeared to sympathize in his confirmation hearing with lawmakers’ concerns about transfers, had pressed his staff after taking office about the details of proposed transfers — security guarantees in particular.

“It’s true to say that he scrutinizes everything we do with this in a way that really presses people to think about the risk,” the first official said. By U.S. law, the defense secretary must personally vouch for the safety of all detainee transfers.

Last month, Carter signed off on the transfer of Shaker Aamer, a British resident who was cleared for release in 2010 but whose release was not approved by previous defense secretaries. He also approved the repatriation of a Mauritanian detainee, Ahmed Ould Abdel al-Aziz, a deal that U.S. diplomats had lined up as early as 2009.

Younis Abdurrahman Chekkouri, a Moroccan, was finally sent home in September, but officials said that the Moroccan government agreed to accept him in the summer of 2013.

Pentagon officials think that Carter’s decision to sign off on long-delayed transfers is proof of his commitment to closing the prison. But his analytical approach may have also slowed those prisoners’ release.

One former senior Pentagon official said that Carter, who served in the second-highest Pentagon position from 2011 to 2013, “wasn’t necessarily convinced initially” that the prison needed to be shut but appeared to have embraced that goal over time.

No matter what, the former official said, “even if he has had ethical or moral disagreements about shutting it down, he will be the consummate staffer for the president” and try to reduce detainee numbers at the prison.

Pentagon press secretary Peter Cook said that Carter would “continue to expeditiously and deliberately consider the cases of other detainees eligible for transfer in collaboration with our interagency partners.”

“The safety and security of the American people will remain his top priority in that process,” he said.

Officials at the Pentagon said that Carter had tasked additional officials to work on the Guantanamo closure process and had added urgency to a parallel effort to develop a plan for dealing with detainees who, if the prison is closed, would eventually be brought to the United States for trial or indefinite detention.

An earlier attempt to finalize that plan was derailed over the Justice Department’s rejection of an Illinois prison as a site for holding Guantanamo prisoners.

The State Department, which leads negotiations with nations admitting detainees, has now lined up deals with about two dozen countries to take about half of the 54 Guantanamo prisoners who are eligible to be moved overseas. These detainees, none of whom have been charged with a crime, will continue to wait — until Carter approves their moves.

According to multiple officials, the conclusion of agreements to resettle prisoners in their home or third-party countries has long been slowed by repeated rounds of questions posed by Defense Department officials — about the details of security arrangements in countries where detainees will be released, travel restrictions for released detainees or other issues.

“There’s a time for questions, and there’s a time for questions to end,” another U.S. official said.

Further slowing the process, the officials say, is that the detention camp, perched on an isolated corner of Cuba, is primarily accessible by military aircraft, meaning that diplomats from countries considering accepting prisoners, and even officials from other agencies, rely on the Defense Department to arrange access to the facilities there.

Some Pentagon officials have been skeptical of releasing detainees, especially after the political firestorm caused by last year’s release of five Guantanamo prisoners in exchange for Bowe Bergdahl, a U.S. soldier held captive in Pakistan.

Not all recent transfers have gone well. Six months after six detainees were released to Uruguay last year, they were protesting outside the U.S. embassy, demanding greater assistance from the country that locked them up for years.

Most inmates at Guantanamo have been locked up for as long as 14 years without being charged with a crime.

With Obama’s 2017 departure in mind, the National Security Council in July implemented a new deadline for recommending detainees for transfer. Once the State Department finishes negotiations with a particular country, a six-agency review process will begin. Those agencies now have a week to sign off on transfer recommendations that will go to Carter for final approval.

The White House also took steps to ensure that questions about security guarantees are posed in a timely fashion and do not gum up negotiations with countries receiving detainees.

“This is a priority,” said Myles Caggins III, a White House spokesman. “The president’s entire national security team is actively engaged in the effort to reduce the detainee population and ultimately close the detention facility at Guantanamo.”

Several officials said that the deadline has already been blown about a half-dozen times.

Officials said that Carter remained concerned about that effort to resettle prisoners, as politically fraught as it is, and that it will amount to little if the administration is unable to overcome congressional opposition to closing the prison.

Further complicating the White House’s plans to shut the prison is a bill making its way through Congress that would impose tighter rules for transfers, and the fact that the 2016 elections might make lawmakers less likely to support housing detainees on U.S. soil. While those elements are beyond Pentagon control, Carter’s stewardship of the detainee transfer process is certain to be closely watched by the White House.

“It’s time for action now,” one official said. “It takes too long to tee up these opportunities [to] just cram it into the last three months of your presidency.”

Julie Tate contributed to this report.