Guelleh's rise to power commenced when he became an integral part of Aptidon's administration in 1977. As chief of staff, he was responsible for maintaining domestic security. He actively cultivated the support of the armed forces and the RPP. Since its formation in 1979, Guelleh steadily advanced in the party hierarchy. In 1983, he became a member of the party's central committee. In the following years, he served on a variety of party committees and became its vice president in 1996.
As former president Aptidon's health deteriorated, Guelleh assumed increased responsibility for daily governmental affairs. Using his political base within the military and police in addition to the RPP, he developed a solid reputation within the government and party. In particular, he enjoyed strong support from Aptidon and the Issa community—who referred to him by his initials, IOG.
When Aptidon decided not to seek another term because of his deteriorating health, Guelleh became his handpicked successor. During the campaign, Guelleh stressed the importance of economic development, nation-building, and peaceful relations with Djibouti's neighbors. He spoke about the need to maintain an orderly transition in government based on his experience and ties to Aptidon. In the 9 April 1999 election, Guelleh garnered 73.89% of the vote while his opponent, Moussa Ahmed Iddris, obtained only 26.11%. Guelleh dominated in rural districts but still managed to poll 62% in the capital. Despite charges of fraud by the opposition, the Chamber of Deputies certified the elections, and power was transferred from Aptidon to Guelleh on 7 May 1999.