Gibran first said he had no interest in politics, but he later changed his position. In July 2019 a survey by Slamet Riyadi University named him a likely contender in the 2020 Surakarta mayoral race. He joined PDI-P, his father's party, and the party endorsed him in July 2020, pairing him with council speaker Teguh Prakosa. Most parties represented on the city council backed him, the Prosperous Justice Party being the exception, and an independent candidate, the tailor Bagyo Wahyono, also entered the contest. Gibran won 86.53 percent of the vote, around 225,451 ballots. He served as the 18th mayor of Surakarta from February 2021 until July 2024, when he resigned to take up the vice presidency and Vice Mayor Prakosa was sworn in to succeed him. In 2021 the Indonesia Indicator survey named him the most popular mayor, a recognition linked by observers to his closeness to his father and to the city's pandemic response.