Are we closer to closing Guantanamo? It’s beginning to look that way.

Earlier this week the Republican-led House and the Democratic-led Senate reached a compromise as part of an annual defense policy bill that would make it easier to transfer detainees from Guantanamo to foreign countries willing to take them. And while many in the press interpreted the news as evidence that Gitmo was here to stay, the bipartisan deal was actually a watershed moment in the long saga. It was the first time since Obama signed his original executive order that Congress moved to make it easier–not harder–to close the 12-year-old facility.

“It’s as if the president finally decided to flip the on-switch and the White House and Defense Department got up and running to work towards closing Guantanamo,” says Christopher Anders, senior legislative counsel at the American Civil Liberties Union. “And it paid off, with a big Senate vote supporting easing some of the transfer restrictions.”

There were many factors that led to this rare bit of tangible progress on Gitmo. Among them was a political climate that had been steadily shifting away from concerns about national security--especially as the country absorbs the reality that U.S. forces will be largely out of Afghanistan by year’s end. Meanwhile, Washington has been preoccupied with all-consuming battles over debt ceilings and sequestration. And in a time of austerity, arguments about the high cost of maintaining the controversial prison started to gain considerable traction with moderate Democrats and even some Republicans.

But it is also the case that the Guantanamo stalemate began to give way to progress because of a resolute push by Obama as well as a willingness to spend political capital that was not always present during the president’s first term. Obama drove his advisers hard and pushed them to regularly update him on progress. And crucially, he made sure that his team engaged Congress, both to win the cooperation of lawmakers but also to signal that closing Guantanamo was one of the highest priorities of his second term.

Obama first signaled his re-commitment to closing Gitmo last April during a press conference when he was asked about a hunger strike at the prison that had spread to about 100 inmates. Speaking with intensity, the president pledged to rededicate himself to the challenge of shuttering the prison. “Guantanamo is not necessary to keep us safe,” he said, tapping at the lectern. “It is expensive. It is inefficient . . . It is a recruitment tool for extremists. It needs to be closed. I’m going to back at this,” he said.

His seemingly impromptu remarks stunned people who had followed the Gitmo ordeal closely. It had been the most Sisyphean of policy initiatives, one that had collapsed early in the first term, done in by congressional obstruction and political realities–but also by the president’s own refusal to expend political capital on the issue. In the years after the effort had stalled, Obama barely mentioned the name of the prison. (The last time he’d invoked Guantanamo at a State of the Union address was in 2009.)

And yet all along, it seemed, Obama’s failure to live up to one of the most high-profile promises of his presidency had tugged at his conscience. In the fall of 2011 Obama had included the prison on a list of goals where he felt he’d fallen short. According to Double Down, Mark Halperin and John Heilemann’s account of the 2012 campaign, Obama told advisers that notwithstanding congressional obstructionism, he felt he hadn’t tried hard enough and had succumbed too easily to the politics of the moment. “No one is going to persuade me that we should run a penal colony in perpetuity in America,” he said, according to Halperin and Heilemann.

But it wasn’t until last spring that Obama’s desire to redouble his efforts became public, forced to the surface by hunger-striking prisoners. A few weeks later Obama fleshed out his ideas for closing Guantanamo in a major national security speech at the National Defense University in Washington. During the speech Obama announced some unilateral actions he would take, such as lifting the ban he had imposed on transferring dozens of Yemeni detainees who’d been cleared for transfer back to their insurgency-wracked country. But what he could not answer was how he would break the political logjam in Congress. He had no obvious solution for persuading Republicans to lift the series of onerous restrictions they had placed on the administration’s ability to transfer detainees out of Gitmo.

The answer to that question was more ineffable; it was about presidential leadership–the power of persuasion–and, ultimately, Obama’s own will to act. Within his own administration, Obama had to jump-start a policy that had effectively ground to a halt in 2011. In meetings he exhorted his advisers to move expeditiously, telling them that he didn’t want a single prisoner left in the offshore prison by the time he left office. And while he acknowledged that it would impossible to empty Gitmo in the face of the congressional restrictions, he insisted that that could not be an excuse for inaction.

Obama imposed a system of accountability within his administration to ensure that the policy didn’t drift, as it had during his first term. He began a search for Gitmo special envoys at both the State Department and the Pentagon, senior officials who would “wake up everyday asking themselves” how they had advanced the cause of closing the prison, as a senior adviser to Obama puts it. The president required Secretary of State John Kerry and Defense Secretary Chuck Hagel to give him weekly progress reports on the effort. And he placed the broad initiative under the direction of Lisa Monaco, the White House counterterrorism and homeland security adviser. One of the first things he directed Monaco to do was develop a timeline of goals and objectives that he could measure progress against.

The first visible sign of movement to close watchers of the politics of Gitmo came in early June when Senators Dianne Feinstein and John McCain traveled together to Guantanamo. Congressional delegations to Gitmo are not uncommon. But this time a notable figure was tagging along on the trip: Denis McDonough, the newly installed White House chief of staff and probably Obama’s most trusted adviser. Feinstein had mentioned her plan to visit Guantanamo to Obama, who suggested that McDonough join them.

For McCain’s part, he had recently been honored at a lunch given by Senate Minority Leader Mitch McConnell for the 40th anniversary of McCain’s release from a Vietnamese prisoner of war camp in 1973. During the trip, McCain shared his insights with Feinstein and McDonough about the true nature of indefinite detention. At one point while touring the facility, some of the detainees began shouting out slogans about the injustice of their detention and that America did not truly stand for freedom. Feinstein, who as a local politician in California had worked on prison conditions in the state, was struck by the extreme isolation of the detainees. “It was a powerful moment,” according to a staffer who accompanied the delegation.

Feinstein returned from the expedition determined to take up Guantanamo as a legislative cause. “She came back on fire,” recalled one staffer. She joined forces with Dick Durbin, the Democratic senator from Illinois, calling on the Pentagon to end the wide-scale force feeding of Gitmo hunger strikers and imploring the administration to put forth a detailed plan on how it would achieve the facility’s closure.

McCain’s public response was more muted, perhaps in deference to his close friend Lindsey Graham, the South Carolina Republican who was facing a tough reelection bid. But one source who accompanied McCain on the Gitmo visit said the Arizona senator “had reached a point where he believed it was un-American to hold people without charges for so long, especially when there were other options.”

Still, outwardly there was little evidence of progress during the first part of the summer. The administration insisted it was stymied by congressional restrictions on transferring detainees out of Guantanamo. Human rights organizations and a growing number of Democrats in Congress contended the White House could use its existing authority to transfer prisoners whom they’d determined could be safely resettled or repatriated.

Beginning in 2011, Congress had passed legislation requiring that the secretary of defense “certify” that released detainees would not return to the battlefield. The administration rightly argued that that was an impossible standard to meet. But the following year Sen. Carl Levin, the Democratic chairman of the Senate Armed Services Committee, managed to push through new legislation that allowed the administration to waive the certification requirements under certain conditions. He and other Democrats believed the move meant Obama could start moving detainees out of Guantanamo. But White House lawyers disagreed, arguing that the restrictions still tied their hands.

To many it was the old dynamic repeating itself: depending on how you looked at it, Congress was throwing insurmountable obstacles in the administration‘s path, or Obama lacked the will to act with conviction.

By mid June the White House was poised to make its first personnel move on the Gitmo front, naming Cliff Sloan to be the State Department’s special envoy for the closure of the prison. Skipping a long-planned family vacation to England and Scotland, Sloan, a Washington lawyer, got to work right away, traveling to Guantanamo the day after his July 1 official appointment. Later that month he was making his first whirlwind foreign trip to identify countries that might be willing to take detainees. But he faced a stark challenge. Before Congress had imposed its restrictions in 2011, the administration had managed transfer 67 prisoners from Guantanamo (out of a total of 241). Between then and Sloan’s first Gitmo trip, not a single prisoner had been repatriated or resettled. Sloan returned stateside with no encouraging news.

Meanwhile familiar tensions over Gitmo were playing out between Congress and the White House. On July 15, Feinstein and Durbin met with Monaco and White House Counsel Kathryn Ruemmler. The meeting didn’t go well. Feinstein and Durbin were frustrated that the administration was not thinking more creatively about how to get out of the Guantanamo box, including using all of its existing authority to start transferring detainees.

Durbin, in particular, was fuming when he left the meeting, according to a knowledgeable source. Stoking his anger may have been his belief that the White House was seeking to undermine a hearing he was about to hold on Guantanamo–the first such hearing in five years. The White House refused to allow anyone from the administration to testify. Either way, both Feinstein and Durbin saw the meeting as a useless exercise, according to a congressional source.

A few days later, Durbin held his hearing, and he let his frustration show. “I’ll be the first to acknowledge that the administration could be doing more to close Guantanamo,” he groused during his opening statement. Feinstein, in a show of her own personal commitment to the issue, attended the entire hearing even though she did not sit on Durbin’s Judiciary subcommittee.

While it appeared that the Gitmo effort was stagnating again, there were important developments taking place behind the scenes. Among them were the persistent efforts of a single congressman to pry out of the Pentagon the true costs of running Guantanamo. Adam Smith, a brainy and intense Democrat from Washington State, had been a passionate supporter of shuttering Gitmo from his perch as the senior Democrat on the House Armed Services Committee. And although the GOP-led House was not likely to pass legislation to close the camp, there were other tacks Smith could pursue. He and his staff kept banging away at the Defense Department to get the Gitmo budget numbers.

By early July they had what they were looking for. It came in the form of a letter to Smith from Defense Secretary Hagel. As Smith’s staff crunched the numbers, they learned that the government was spending $2.7 million per detainee, per year. It was an astonishing amount of money to be spending in perpetuity on 166 detainees, most of whom hadn’t been charged with a crime and many of whom had no connections to terrorism, let alone 9/11. In contrast, the federal government spent $78,000 a year per prisoner at the Supermax prison in Florence, Colo.

"The cost of keeping Guantanamo open is just staggering and completely unnecessary,” says Ken Gude of the Center for American Progress, which just put out a report on Gitmo costs. “Even this Congress can't ignore wasting billions of dollars on holding detainees that have already been cleared for transfer out of the prison camp," adds Gude.

Smith understood that in an era of austerity, sequestration, and government furloughs, the Gitmo numbers would likely have a big impact on moderate Democrats and even some fiscally minded Republicans. “This was the one thing that changed the debate,” Smith said in an interview this week.

For Cliff Sloan, the cost argument would turn out to be a powerful weapon when he began to lobby the Hill in mid-summer. A mild and affable lawyer, Sloan also knew his way around Capitol Hill. He was well aware of the fractious history between Congress and the White House on Gitmo and was determined to start anew. He told members of Congress and their staffs that it was “an era of new possibility” and that he didn’t intend to “relitigate” the old fights. He said that the administration would do everything it could possibly do under existing authorities to transfer out detainees. At the same time, Sloan argued that real progress would require Congress to lift at least some of the restrictions.

Sloan won plaudits from members of Congress for methodically taking apart many of the arguments deployed by opponents of closing Gitmo. Legislators were grateful for that kind of sustained engagement. Gone were the days when former Chief of Staff Rahm Emanuel imposed a fatwa on administration staffers briefing Congress on Guantanamo because he didn’t want the controversial issue to interfere with the president’s domestic agenda.

But Sloan's most powerful argument was financial. It got particular traction with red-state Democrats who had never been enthusiastic supporters of closing Guantanamo. It gave senators like Max Baucus of Montana and Jon Tester of Wyoming a new way to talk about Guantanamo that would resonate their constituents. “They didn’t have to make the same old arguments about civil liberties,” says one Senate source familiar with the strategy.

By August, the administration had a new legislative proposal to rally around. Sen. Levin, acceding to the White House’s wishes, wrote new language for the upcoming 2014 defense policy bill that would lift the most onerous restrictions placed on the executive branch to transfer detainees out of Guantanamo. The president would effectively be able—at his discretion--to move detainees to foreign countries willing to take them, and he’d even be allowed to transfer them to the U.S. homeland for medical reasons or detention and trial.

Levin craftily moved the language straight to the Senate floor, bypassing a vote on the Armed Services Committee where the proposal would have likely been watered down. Sloan and Paul Lewis, the Pentagon’s special envoy for Gitmo, lobbied the Hill throughout the month of August. But the White House brought out the big guns when the White House came back into session, sending Lisa Monaco up to lobby individual senators and their staffs on multiple occasions. Monaco also invited senators down to the White House Situation Room to make her case. In addition, the White House legislative affairs staff stormed the Hill with meetings and calls.

Soon Obama himself had gotten into the lobbying action. On September 2 he met in the Oval Office with McCain and Graham. Publicly the meeting was billed as an effort to win over the two powerful senators’ support for the administration’s Syria policy at a time when U.S. military action seemed imminent. But according to two administration officials familiar with the meeting, Obama took the opportunity to make his case for closing Guantanamo.

McCain, who had supported closing the prison during the 2008 presidential campaign, kept his counsel but seemed open to supporting the Levin language. As for Graham, Obama knew that there was no chance of winning his vote. Facing a primary challenge in South Carolina, Graham needed to stay to the right of Obama on national security. The game with Graham, who in the past had supported the administration on Guantanamo, was trying to persuade him not to actively and openly oppose Obama on the issue. On that score, Obama thought he had a chance.

The real test of Obama’s legislative muscle came in the fall when Republican Senator Kelly Ayotte tried to kill the Levin language with an amendment that would have kept all of the Gitmo restrictions in place. Monaco and White House lobbyists continued to work the phones, while the White House organized a barrage of letters to the Hill from top national security officials, including Hagel, Kerry, and Attorney General Eric Holder Jr. Meanwhile Obama continued to signal that the initiative was a presidential priority. On November 4 he met with both of his Gitmo envoys. During the meeting, according to a source who was present, Obama told Sloan and Lewis that he was prepared to do whatever they needed to help them succeed in their mission–whatever “blocking and tackling” that was necessary, as Obama put it.

But in some ways it was the visual image of the meeting that was most important. The White House released a picture of Obama with his envoys, and National Security Council spokesperson Caitlin Hayden tweeted out news of the meeting. The lobbying offensive lasted right up until the vote. On November 19, the White House was able to beat back the Ayotte amendment. Crucially they won three Republicans to their side, including McCain, whose position wasn’t known until shortly before the vote.

McCain told colleagues that he had been in discussions with the highest levels of the White House, which colleagues interpreted to mean Obama himself, according to one Senate staffer. For his part, Graham didn’t take to the Senate floor to attack the administration’s position, as he had on other occasions.

Having McCain on board gave Senate Democrats momentum going into negotiations with the House earlier this month. And while supporters of the prison’s closure hardly got everything they wanted (the ban on transferring detainees to the U.S was maintained) the administration now has a freer hand to start emptying out the facility. For a president who believes in playing the long game, this was an inflection point. “Momentum begets momentum,” one of Obama’s senior advisers observes, savoring the rarest of things for this White House: a victory on Guantanamo.