The Cresswell building will be transformed to allow it to provide a range of out-patient and day-case services.
Maternity services are due to transfer to a new hospital being built in the town by the end of the year.
It means that the old unit - which opened in 2002 - can now be converted to a new use.
The Cresswell building was funded via a Private Finance Initiative (PFI) which still has about 16 years left to run on its contract.
With payments of about £3m-a-year NHS Dumfries and Galloway decided it was better to redevelop the building rather than leave it sitting empty.
It will be renamed the Mountainhall Treatment Centre and will reopen in 2020.
NHS Dumfries and Galloway chief executive Jeff Ace said: "Scottish government support for this project enables us to deliver the final phase of our modernisation of acute services in the region.
"This new day treatment facility will provide a great environment for patients and staff and will be designed to meet latest service requirements.
"This is another major project for the board and continues our commitment to provide the best possible healthcare facilities for the people of Dumfries and Galloway."
Health Secretary Shona Robison said she was delighted to support the new facility.
"With the new district general hospital opening later this year, this is an exciting time for the health service in Dumfries and Galloway," she said.
"I know the revitalised Cresswell building is a key part of the board's plans for out-patient and day-case services."
Katy Lewis, director of finance for NHS Dumfries and Galloway said it meant they could now progress with plans to refurbish Cresswell.
"This is excellent news for the local community to complement the hospital provision in the new DGRI building," she said.
A £14m maternity unit conversion plan in Dumfries has been approved by the Scottish government.