BAGHDAD — After a second day of tense protests at the American Embassy in Baghdad, thousands of pro-Iranian demonstrators dispersed on Wednesday, ending a siege that had trapped American diplomats in the embassy compound overnight and winding down a potentially explosive crisis for the Trump administration.

The demonstrators had swarmed outside the embassy, chanting “Death to America!” Some tried to scale the compound’s walls, and others clambered onto the roof of the reception building they had burned the day before.

In contrast to Tuesday, when some demonstrators forced their way into the compound and set some of the outbuildings on fire, the crowd on Wednesday was smaller and no protesters breached the compound’s gates.