Last-minute deal could avert a collision course at the UN