HARARE, Zimbabwe — Tens of thousands of Zimbabweans gathered in the capital on Saturday, hooting, whistling and hugging soldiers as they called for President Robert Mugabe to give up power, days after the military placed him under house arrest.

In scenes perhaps unthinkable only weeks ago, people marched side by side with members of the military — who rode in armed tanks — and the protesters hailed the army as setting them free from Mr. Mugabe’s 37-year autocratic rule.

“Mugabe must go, and his goons must leave. We have been victimized by Mugabe for too long,” said Nigel Mukwena, a 24-year-old student of political science at the University of Zimbabwe.

Others took selfies of the military at the rally, which converged on Zimbabwe Grounds, known as the site of addresses by Mr. Mugabe and other icons of the nation’s liberation. The scenes, and the celebratory air, were a seminal shift for the country’s 93-year-old leader — Africa’s oldest.