The Oamaru Courthouse is to be reopened and restored, under an agreement reached by the Justice Minister and the Waitaki District Council.
The courthouse - built in the late 19th century - was closed in December 2011 because it failed to meet minimum earthquake standards.
Ownership of it will be transferred from the Ministry of Justice to the council, which will strengthen the building and lease it back to the ministry.
Justice Minister Amy Adams said the council would be able to use it outside court sitting hours for council-related activities.
She said the courthouse would be ready for use by the end of the year.