The chief executive of NHS Scotland will step down early next year after more than five years in the role.
Health Secretary Jeane Freeman paid tribute to the "excellent" work done by Paul Gray.
She also announced the man sent in to take over the running of NHS Tayside after it was hit by financial scandal will take over the post on an temporary basis.
Malcolm Wright will serve as interim chief executive when Mr Gray leaves the job in February 2019.
Ms Freeman also confirmed a new permanent chief executive has been appointed to lead NHS Tayside – which has a projected deficit of £18.7 million for 2018-19.
Her predecessor as health secretary, Shona Robison, was forced to intervene in the running of the board after it emerged cash from public donations had been used to fund new technology.
Meanwhile, an independent inquiry is being carried out into mental health services in the area after concerns were raised about the Carseview psychiatric unit at Ninewells in Dundee.
The Health Secretary said: "Paul Gray has been an excellent chief executive of the NHS in Scotland and director-general of health and social care.
"Amongst his many achievements in this role, which was just the most recent in a long and distinguished career in public service, Paul oversaw the integration of health and social care services, which is the most significant change to our health system since the creation of the NHS."
She added: "Paul will remain in post until February, continuing to lead health boards throughout the winter months.
"I would like to offer him my sincere and personal thanks for his work over the last five years and my best wishes for the future contribution I know he will make.
"I look forward to working with Malcolm Wright, who brings a wealth of senior management experience to the role.
"I am also pleased to announce the appointment of Grant Archibald as chief executive of NHS Tayside.
"He also has a strong background with more than 30 years of experience in the health service, including a number of senior roles."