Lock said he texted to a mate about his predicament and gave him his co-ordinates. His friend alerted the Coastguard, which then contacted the Rescue Co-ordination Centre New Zealand (RCCNZ).
An ocean tanker was diverted to help Lock.
"A tanker came past me and circled around. They yelled out and asked if I was all right.
"It was pretty hard to hear them, they were about five storeys up on the deck. I pointed at the motor and crossed my arms," Lock said.
"They carried on."
During a subsequent phone call to the rescue centre he swore at those trying to help him.
"Yeah I was getting worried and agitated by this stage. It was getting dark and the wind was blowing offshore. I did swear at them."
He was told a tug had been sent from Opua and it would tow him to safety.
"I was looking on the horizon for a boat that didn't seem to be coming."
Lock attached bright lights to the outside of the boat to make it more visible to his rescuers.
Whangarei-based police Search and Rescue co-ordinator Constable Jim Adamson said because the stricken boatie was not anchored it was difficult to pinpoint his location so the Northland Rescue Helicopter was sent to search.
Donna Britain, a crew member on the tug boat Albatross V, spotted the lights after an initial search of the area, skipper Warren Haslip said. The boat was towed back to Opua, arriving just after midnight.
Rescue Co-ordination Centre spokesman Mark Dittmer said people needing rescue were under high levels of stress.
"While the man was not the politest person we've ever rescued and did use a few four-letter words, his behaviour was understandable in the situation," Dittmer said.
"This guy is really lucky that anyone knew he was missing as he was at the limits of cellphone reception. If he hadn't been able to contact his friend, he might still be floating around out there."
Adamson said the rescue operation had cost emergency services about $15,000. It highlighted the need to be better prepared when heading that far out to sea in a small vessel.
"You must take at least two forms of communication and inform people of your trip intentions."