SÃO PAULO, Brazil — The protests were heating up on the streets of Brazil’s largest city last week, but the mayor was not in his office. He was not even in the city. He had left for Paris to try to land the 2020 World’s Fair — exactly the kind of expensive, international mega-event that demonstrators nationwide have scorned.

A week later, the mayor, Fernando Haddad, 50, was holed up in his apartment as scores of protesters rallied outside and others smashed the windows of his office building, furious that he had refused to meet with them, much less yield to their demand to revoke a contentious bus fare increase.

How such a rising star in the leftist governing party, someone whose name is often mentioned as a future presidential contender, so badly misread the national mood reflects the disconnect between a growing segment of the population and a government that prides itself on popular policies aimed at lifting millions out of poverty.

After rising to prominence on the backs of huge protests to usher in democratic leadership, the governing Workers Party now finds itself perplexed by the revolt in its midst, watching with dismay as political corruption, bad public services and the government’s focus on lifting Brazil’s international stature through events like the 2014 World Cup and the 2016 Olympics inspire outrage.