Number 1 Capital Quarter was built as a speculative development and purchased in 2013 to stimulate development in the city's enterprise zone.
The building, which is now fully occupied, has been bought by Global Gate Capital as an investment.
Economy Secretary Ken Skates said the Welsh Government "acted as a catalyst and inspired confidence in the market".
Ministers said they bought the building from its developers to ensure it was completed, providing Grade A office space to attract new investment and jobs.
"The provision of office accommodation of the highest quality has contributed to the success of Central Cardiff Enterprise Zone, enabled existing businesses in the financial and professional services sector to expand and attracted new inward investment," Mr Skates said.
Network Rail and the Welsh Government's own Finance Wales arm are among the organisations based at the premises.
The Welsh Government's purchase of land and buildings for development has faced criticism from opposition parties.
In September, Plaid Cymru AM Neil McEvoy said it was "staggering" that three shops in Pontypridd bought in 2008 for £1.25m as part of regeneration plans were sold in 2016 for £271,000 after plans for a new shopping centre failed to come to fruition.
An office block in central Cardiff bought by the Welsh Government for £14m has been sold for just under £20m.