The agreement came earlier than expected, overcoming previous opposition from Hungary’s Viktor Orban.