The advances are significant victories for the pro-European leadership in a military operation to crush the armed separatist rebellion that began in east Ukraine in April and hold the former Soviet republic of 45 million together.
Interior Minister Arsen Avakov wrote on Facebook: "The Ukrainian flag was raised over City Hall in Mariupol."
A ministry aide said the government forces stormed the rebels after they were surrounded.
At least five separatists and two servicemen were killed in the battle before many of the rebels fled.
Mariupol, which has changed hands several times in weeks of conflict, is strategically important because it lies on major roads from the southeastern border with Russia into the rest of Ukraine and steel is exported through the port.
Regaining control of the frontier is also vital for the government because it accuses Moscow of allowing the rebels to bring tanks, other armoured vehicles and guns across the border.
The new president, Petro Poroshenko, intensified the military operation against the rebels after he was elected last month.