The attack on Ghazni city began overnight on Friday.
Within hours, the Taliban claimed to have much of the capital under their control.
US attack helicopters and drone aircraft provided government forces with air support.
Defence Ministry spokesman Mohammad Radmanish later said the army supported police and the city was now under control of government forces.
Al Jazeera’s Charlotte Bellis, reporting from Kabul, said it was unclear how much of Ghazni was under government control as residents said they could still hear heavy gunfire and rockets.
“There are conflicting reports as residents say the Taliban has taken control of checkpoints across the city from the police.
“[But] the police, the government and the US are denying that claim, saying they have pushed back the fighters.”
At least 14 security forces were killed and 20 wounded in the battle, said Baz Mohammad Hemat, administrator of the Ghazni city hospital.
Dead bodies of Taliban fighters remained on the street after the exchange, provincial police chief Farid Ahmad Mashal told the Associated Press news agency.
He said the bodies of 39 Taliban soldiers were recovered beneath a bridge in the southern edge of the city.
Air strikes called in to quash the offensive also killed dozens of Taliban, he said.
All shops in the city were closed due to the fighting. The road from Kabul to Afghanistan’s southern provinces was also closed because it runs through Ghazni.
The attack on the strategic city, which straddles the main route between the capital Kabul and southern Afghanistan, demonstrated the Taliban’s strength amid speculation of a possible ceasefire during the Eid holiday this month.
In June, a three-day truce over the Eid al-Fitr holiday brought unprecedented scenes of unarmed Taliban fighters mingling with security forces in Kabul and other cities, offering a glimpse of peace and fuelling hopes of negotiations to end the war.
The Taliban have so far failed to take and hold any provincial centre since they overran the northern city of Kunduz in 2015 before being driven off, with the support of US air strikes and Special Forces units.