He is possessed by the heartless and assimilated into the darkness and later his corporeal envelop is used as the manifested form of the mastermind behind the Heartless, Master Xehanort.
King Mickey became friends with Ansem when landing in Ansem's world during Mickey's exploration of the universe. Many details on Ansem are unknown except that he was a scientist, mage and king of his world and beloved by his people as a good and wise king. Ansem's attempts to unlock the power of the human heart is ultimately what brought the Heartless into being and consumed his world in the process. Master Xehanort used not only Ansem's form but name to first interact with the physical world in the first game.
Whether Ansem's heart still exists in his body or is lost some place in the darkness is unknown but the current creature calling it self Ansem is not the same once wise king who existed before the start of the game.