Gibała, who ran for the "Kraków for Residents" committee, received 161,184 votes.
Monika Piątkowska, backed by ruling Civic Coalition (KO) and the PSL, received 98,306, or 37.88 percent.
Turnout was 44.27 percent.
Gibała had topped the first round with 36.38 percent, ahead of Piątkowska on 29.91 percent, but neither candidate secured the majority needed to win outright, sending the race to a run-off.
His victory is seen as a political setback for Prime Minister Donald Tusk’s governing coalition, which lost control of the city after its mayor was recalled in May.
Speaking to journalists on Sunday, Gibała said he felt no triumphalism and was already in "task mode, not celebration mode."
He named repairing public finances, over-tourism and major transport problems as priorities, and said he must first build a majority on the city council.
Gibała also criticised the stream of national politicians who came to Kraków during the campaign, calling it unserious and at odds with the idea of local self-government.
Foreign Minister Radosław Sikorski and Finance Minister Andrzej Domański had campaigned for Piątkowska in recent weeks.
Gibała said he would meet the KO-backed candidate, who is a senator, as soon as possible, and hoped she would use her government contacts to lobby for Kraków.
He added that he expected PM Tusk and his ministers to remain professional and not take offence at his victory.
Cooperation with the government was "absolutely essential," whichever party is in power, Gibała told reporters.
As an independent mayor, he said, he was ready to work with both the current government and any future one, but on equal terms – not "as some kind of petitioner."
Gibała marked the first day after his win by handing out obwarzanki (ring-shaped bread) to residents.
The early election followed a referendum in May in which Mayor Aleksander Miszalski was voted out of office.
Gibała is expected to be sworn in at the next city council session on 21 October.
(ał)
Source: IAR, PAP, tvn24.pl