The deal follows months of back channel diplomacy by Washington’s top hostage negotiator and other U.S. officials secretive talks with a major oil producer that took on greater urgency after sanctions on Russia put pressure on global energy prices.