Rescuers in Sydney received a call on Thursday afternoon that the whale had become entangled and raced under fading light to save it.
By dawn, rescuers followed the whale in an inflatable boat and used specialised equipment to hold the whale in place while they cut the debris away.
The whale was freed shortly before midday on Friday, and swam off to the open ocean after its 22-hour ordeal.
Jessica Fox, from the Organisation for the Rescue and Research of Cetaceans in Australia, told AFP that efforts to save the whale were "incredible".
"It is not uncommon for a whale to enter Sydney Heads -- they pop their heads in time to time, but to have one entangled in Sydney Harbour is extremely rare."
For decades, humpback whale populations were hunted to the brink of extinction -- at one stage there were only an estimated 1,500 of the animals left in Australian waters.
But they are a rare conservation success story after global protections were afforded to the whales in 1965.