Three years of war have upended alliances, weakened US influence and reshaped the region’s power balance.