WASHINGTON — When Prime Minister Matteo Renzi of Italy visited the White House in October for a state dinner, he made a commitment to President Obama: Italy, which resettled a Yemeni detainee from Guantánamo Bay last summer, would take one more person on the transfer list. But before the deal was completed, Mr. Renzi resigned.

So a day after his successor, Paolo Gentiloni, formed a government on Dec. 14, Secretary of State John Kerry called to congratulate Mr. Gentiloni — and to urge him to follow through on the commitment, according to an official familiar with the negotiations. Mr. Gentiloni agreed, leading a rush to finalize the details and paperwork.

The effort was part of a burst of urgent, high-level diplomatic talks aimed at moving as many as possible of Guantánamo’s 22 prisoners who are recommended for transfer. By law, the Pentagon must notify Congress 30 days before a transfer, so the deadline to set in motion deals before the end of the Obama administration was Monday.

By late in the day, officials said, the administration had agreed to tell Congress that it intended to transfer 17 or 18 of the 59 remaining detainees at the prison; they would go to Italy, Oman, Saudi Arabia and the United Arab Emirates. If all goes as planned, that will leave 41 or 42 prisoners in Guantánamo for Donald J. Trump’s administration. Mr. Trump has vowed to keep the prison operating and “load it up with some bad dudes.”