BAGHDAD — Tens of thousands of Iraqis marched Friday at the ­urging of popular Shiite cleric ­Moqtada al-Sadr, decrying U.S. influence in the country and demanding that Washington withdraw its troops.

Around Baghdad’s Hurriyah Square, the streets were a sea of black, white and red, as protesters clutched Iraqi flags and wore shrouds around their shoulders. Iraq’s government is under growing pressure to expel foreign troops after a U.S. drone strike here killed Iran’s most powerful military commander, inflaming regional tensions and leaving Baghdad’s politicians fuming.

At the march Friday, loudspeakers denounced U.S. troops as occupiers. Posters depicted President Trump hanging from a noose. The anthems of Sadr’s years-long militancy against U.S. forces blared.

But the march itself was both disciplined and short, a set piece that made its point vociferously but dispelled fears of violent ­confrontation. Despite supporting Friday’s so-called “million-strong” march, the Iranian-backed militias that have clashed with U.S. troops here had no obvious presence, and the tone of the day was strictly nationalist.

“Americans came to our country talking of freedom and democracy,” Qayser al-Saad, 23, from Baghdad’s Sadr City, said as he clutched at his sleeves on a bitterly cold day. “Today we’re asking them to leave so we can have just that. It won’t happen in a homeland occupied by foreigners.”

After a period of relative stability, Iraq has been roiled by unrest since the fall. Anti-government protesters have repeatedly clashed with security forces, and more than 500 people have been killed, most of them young, unarmed men. The unrest has toppled a government and won mild electoral changes. But as protesters ramp up pressure for meaningful change, riot police have fired bullets into crowds and launched tear gas canisters heavy enough to smash skulls.

On Baghdad’s streets Friday, Iraq’s competing political currents were on full display. If the anti-American march appeared closely controlled by the political factions that had called it, the scene of anti-government protests was messy. Tahrir Square in central Baghdad was filled with tents, and crowds were smaller than before. Young men and boys strolled toward the site of days-old clashes — quiet at the moment, but seemingly part of a recipe for further bloodshed.

The months-long protests are leaderless, as activists reject the control of what they see as a corrupted political system. They, too, have demanded an end to foreign interference in Iraq’s politics, decrying U.S. and Iranian influence in equal measure as they watch brinkmanship between the two inflame proxy battles here.

“We don’t want any of them. We don’t,” Abbas Ali, a 31-year-old grocer, said in Tahrir Square on Thursday night. “It’s not just about foreign troops. America built the system we’re living in, and it’s left us with no future. Iran has treated this country like its backyard. We want all of them out.”

Iran-linked militias, which operate alongside Iraq’s conventional forces, have repeatedly ­attacked protesters in Tahrir Square and southern cities, forcing many to leave their sit-ins and sowing fear among those who stay.

“Iraqi security forces have resumed their lethal campaign of repression against protesters who are simply exercising their rights to freedom of expression and to peaceful assembly. This latest escalation is a clear indication that the Iraqi authorities have no intention whatsoever to genuinely put an end to these grave violations,” said Lynn Maalouf, Amnesty International’s Middle East research director.

Many of the young demonstrators at Tahrir had been wary of Friday’s anti-U.S. march, fearing that it might blunt their momentum and boost factions that were already empowered in the wake of the killing of Maj. Gen. Qasem Soleimani, commander of Iran’s elite Quds Force.

In response, Sadr, a pragmatic operator who has supported the anti-government protests, made clear that the two gatherings should not meet. Participants were bused from across Baghdad and the south to join his march, and a separate site was identified for them to rally before Friday prayers.

The cleric did not attend the event, but demands in his name were read aloud by a representative and were echoed widely on signs in English and Arabic held by the marchers.

Calling on Trump not to be “arrogant” when addressing Iraqi officials, the message demanded that all foreign forces leave Iraq, that security agreements between Iraq and the United States be canceled and that Iraqi airspace be closed to U.S. military aircraft.

“If all this is implemented, we will deal with [the United States] as a non-occupying country. Otherwise it will be considered a hostile country,” the statement said.

When the country’s prime minister asked last week that U.S. officials provide a timetable for withdrawal, the State Department responded that any discussion with Baghdad would center on whatever force size the Trump administration determines is sufficient and that “America is a force for good in the Middle East.”

In a weekly sermon Friday, Grand Ayatollah Ali Sistani, Iraq’s leading Shiite cleric and a significant voice in times of crisis, threw his weight behind peaceful protests in support of Iraqi sovereignty and urged lawmakers to implement “real reforms.”

“Procrastination in this matter will only lead to more suffering,” his statement said.

Mustafa Salim contributed to this report.