HARARE, Zimbabwe — He was an unknown pastor, upset about the hardships of daily life in Zimbabwe.

But when he posted a protest video on Facebook, wrapping himself in the national flag, the Rev. Evan Mawarire became one of Zimbabwe’s first social media stars, the embodiment of widespread grievances against President Robert Mugabe. His subsequent posts on Twitter helped set the stage for the biggest protest against the government in a decade in the capital, Harare, in early July.

The Zimbabwean government, which had initially dismissed Mr. Mawarire, grasped the danger that the pastor — and social media — posed, potentially more dangerous than anything Mr. Mugabe had faced during his 36 years in power.

Responding with the same ruthlessness with which it had dispatched critics over the years, the government jailed the pastor, took him to court and told him to leave Zimbabwe.

The pastor, who fled with his family to South Africa and then to the United States, now says he is “definitely not going back to Zimbabwe anytime soon.”