We compute welfare gains from trade in a dynamic, multicountry model with capital accumulation and trade imbalances. We develop a gradient-free method to compute the exact transition paths following a trade liberalization. We find that (i) larger countries accumulate a current account surplus, and financial resources flow from larger countries to smaller countries, boosting consumption in the latter, (ii) countries with larger short-run trade deficits accumulate capital faster, (iii) the gains are nonlinear in the reduction in trade costs, and (iv) capital accumulation accounts for substantial gains. The net foreign asset position before the liberalization is positively correlated with the gains. The tradables intensity in consumption goods production determines the static gains, and the tradables intensity in investment goods production determines the dynamic gains that include capital accumulation.