The 1883 Thames St courthouse was closed in late 2011 after being classed as earthquake-prone, before court services were relocated to Timaru, then nearby Oamaru Opera House and finally to a portable facility in Humber St in 2014.
A close to $900,000 project to earthquake-strengthen and refurbish the courthouse and its surroundings started in February and was completed this week ahead of the ceremony to mark the occasion.
Waitaki Mayor Gary Kircher said the building being reopened was a "great day" for Oamaru.
"We all know the story. Earthquake-strengthening was an issue and it was going to cost a fortune to fix it. We didn't really know what was going to happen."
He paid tribute to Oamaru lawyer Bill Dean who criticised an initial Ministry of Justice estimate of up to $6million to earthquake-strengthen the courthouse - a cost estimate ridiculed and disputed by the Oamaru community.
Mr Dean had Dunedin engineer Lou Robinson and a local surveyor assess the building and the cost of strengthening it to 100%.
They came up with a figure of $300,000 to $350,000.
Speaking at the ceremony, Justice Minister Andrew Little said courthouses played a "very important" role in all towns and cities as each courthouse "stamps its authority" on the area it's in.
He praised the Waitaki District Council for its proactive stance on the issue and its desire to preserve the town's architectural history.
Waitaki MP Jacqui Dean was equally impressed with the outcome and said "many people cared" about the building.
She criticised the temporary facility on Humber St, which she said was not up to scratch in terms of safety and security, and said while the future of the historic courthouse was uncertain she had a "not completely happy relationship" with her party.
Speaking on behalf of the Otago branch of the New Zealand Law Society, Oamaru lawyer Phil Hope said the Oamaru legal fraternity was excited to be returning to the building, and the temporary facility was "unsuitable, not fit for purpose", and that the drawn-out process to reopen the courthouse had taken "far too long".
A date for the return of court services to the building has yet to be confirmed by the ministry.