Portland Bay limped back into Port Botany, which it left on Monday morning, before losing power off the coast as wild weather struck Sydney.
Crews worked day and night to handle the emergency in swells up to 11 metres.
At one point, a tow line attached to the ship snapped, and efforts to airlift some of the crew off were abandoned due to the wild weather.
It finally docked alongside at Port Botany in Sydney’s south, just before 3pm on Wednesday, after three days without power.
Incident controller John Finch said it had been a “really challenging” time in “atrocious weather conditions”.
He said the main engine problem happened to coincide with the bad weather and admitted the vessel came to a “precarious rest” near the cliffs of the Royal National Park, just south of Sydney.
Finch said the crew only had one chance to successfully get the anchors down, before multiple tug boats could get there.
“All in all it’s a great outcome,” he said.
“No pollution, no injuries, no major damage.
“The ship could have ended up on the rocks. She was half a nautical mile, about a kilometre.
“That’s far closer than you need to be comfortable.”
NSW Premier Dominic Perrottet earlier called those involved in the operation “heroic.”
“It’s been a great team effort,” CEO Port Authority Captain Philip Holliday said.
“There were a couple of points along this where we were looking at a different situation.”
Marine Pilot Lindsay Cavanagh praised the captain and the tugboat crews, who have had little sleep for three days.
“The effort he’s gone to to keep his ships safe is really impressive,” Cavanagh said.
Andy Perry, the operations manager for Engage Towage, said the 21 crew members were “happy” to get back to dry land after a “long ordeal”.
“Morale is high but they’re tired,” he said.
Perry said all people involved in the ship’s recovery had trained for such emergencies and today’s operation had been carefully planned.
He said some of the seamen involved were now able to go home to rest, while others had returned to work.
Some engine power was used to bring the vessel in.
The ship will now be assessed and the engine will be repaired.
The Australian Transport Safety Bureau has started a transport safety investigation.
The incident will also be reviewed and investigated.