Updated

A bipartisan deal reached in Congress that may bring detainees at Guantanamo Bay closer to heading home gives President Obama a rare victory in his fight to close the prison for terror suspects.

The compromise is part of a broad defense bill awaiting final passage in the Senate this week. The House approved the measure last Thursday. It's the first time since Obama came to office promising to close Guantanamo that Congress is moving to ease restrictions instead of strengthen them. And it could signal changing political views of the prison for terrorism suspects now that the war in Afghanistan is winding down.

Obama's achievement was somewhat a surprise, after the Republican-controlled House earlier this year voted overwhelmingly to make it harder to transfer detainees. But the deal to move in the opposite direction passed with hardly any opposition and little attention — perhaps overshadowed by more prominent defense bill debates over Iran sanctions, military sexual assaults and spying by the National Security Agency.

But even with the deal, Obama still faces big obstacles to closing Guantanamo. Congress has effectively blocked him from doing so for his first five years in office, and he faces declining clout in his final three. Yet the president seems determined as part of his legacy to push for closure of the prison he argues never should have been opened and "has become a symbol around the world for an America that flouts the rule of law."

Congressional proponents of keeping Guantanamo open say they felt they had to allow for transfers to other countries to maintain a more important priority — a ban on detainees from coming into the United States. The administration also pushed for the ability to transfer detainees to the U.S. for imprisonment, trial or medical emergencies but lost on that front, leaving Obama a thorny predicament of what to do with captives considered too dangerous to release.

Oklahoma Sen. James Inhofe, who worked on the compromise as the ranking Republican on the Senate Armed Services Committee, said he'll continue to fight to keep Guantanamo open even as some colleagues are softening their position. "There's no place else you can house these terrorists," he said in a telephone interview Wednesday, adding some former detainees have re-engaged in terrorist activity.

"I look at this and I wonder why people don't want it," Inhofe said. "But the president doesn't and he's going to keep trying (to close it). And this bill stops him from doing it."

Obama renewed his commitment to closure this spring when detainees went on a hunger strike to protest indefinite confinement without charge, now going on for 12 years. Obama responded by vowing to make the case anew to Congress that the prison hurts the United States and appointing envoys at the State and Defense Departments to work toward closure.

"Guantanamo is not necessary to keep America safe," Obama said. "It is expensive. It is inefficient. It hurts us in terms of our international standing. It lessens cooperation with our allies on counterterrorism efforts. It is a recruitment tool for extremists. It needs to be closed."

Top administration officials, including Obama counterterrorism adviser Lisa Monaco and State Department envoy Clifford Sloan, made a quiet yet effective lobbying push to convince members to ease restrictions. They pointed out the annual cost of operating Guantanamo has reached more than $2 million per prisoner while other terrorism suspects are kept in U.S prisons at a small fraction of the price.

Senate Armed Services Committee Chairman Carl Levin championed the cause and predicts the resulting compromise could have a dramatic impact on the detainee population.

"About half of the detainees would be detainees that could be transferred to their third-world countries from which they come," Levin told reporters. "About half of the detainees would remain in Guantanamo because of the prohibition on transferring them to the United States for detention and for trial."

Half of the 160 detainees at Guantanamo as of this week were approved for transfer nearly four years ago, provided that the home country could provide security guarantees. But the Obama administration has argued that many approved transfers effectively have been blocked by restrictions imposed by Congress.

For instance, lawmakers have barred the administration from transferring any detainee without the Pentagon certifying that, among other requirements, the receiving country is not "facing a threat that is likely to substantially affect its ability to exercise control over the individual." Administration officials have said that's a bar too high in particular for Yemen, home to the world's most active al-Qaida branch and more than half the Guantanamo detainees.

The rules have prohibited transfers to countries where detainees who have been released previously have re-engaged in terrorism. That includes Kuwait, a key U.S. ally that has been lobbying for the return of its two remaining detainees and has built a still unused rehabilitation center to peacefully reintegrate them.

There's also been a prohibition on transferring detainees to countries that the United States has declared a state sponsor of terrorism. Guantanamo houses three Syrians who have been approved for transfer but would be barred from going home under the current rules. Sudan's government says its two remaining detainees were heading home Wednesday — one has completed a sentence after a conviction on terrorism charges and the other is so ill he's unlikely to pose a threat and was recently ordered released by a judge. Court ordered transfers are excluded from the congressional restrictions; otherwise the administration would not have been able to send even a debilitated prisoner home to certain countries.

The congressional deal lifts those restrictions and allows transfers for those detainees who have been approved when the administration determines the transfer is in the national security interests of the U.S.

Administration officials say they are working with foreign governments to negotiate terms of transfers so there won't be a big movement overnight.

"The president directed the administration to responsibly reduce the detainee population to the greatest extent possible, and we would welcome much needed flexibility in this area," said National Security Council spokeswoman Caitlin Hayden. "But even in the absence of transfer restrictions, our longstanding policy is to transfer detainees only if the threat posed by the detainee can be sufficiently mitigated and when consistent with our humane treatment policy."

The Associated Press contributed to this report.