The long-awaited agreement comes as Donald Trump’s sweeping tariffs and trade threats push countries to seek new partnerships.