Museveni, 74, is the fourth longest serving African president having ruled Uganda for 32 years.
The president, who seized power in January 1986, once said that leaders who overstayed were the root of Africa's problems.
Uganda's First Lady Janet Museveni says her husband has been leading the country for the last three decades because "God chose him."
Mrs Museveni, who is the Minister of Education, was speaking on Thursday during the launch of a water scheme in western Ntungamo District.
“I have been telling people that it is God who has enabled President [Yoweri] Museveni to be in power for this while. Do not think it’s just the elections. God is the one who puts leaders in charge of the people,” she said.
She added that as long as God needed Mr Museveni in power, no one can go against his will.
“If it was not for God’s will, citizens would not vote for him; even the power of the election cannot sustain him. When God has a purpose for you, he will keep you in power,” she said.
Mr Museveni, 74, is the fourth longest serving African president having ruled Uganda for 32 years.
He was elected to a fifth term in February 2016 and would have been ineligible to contest in the 2021 election but for the amendment of Article 102 on presidential age limit in 2017.
The law previously required presidential contenders to be under the age of 75.
Mr Museveni, who seized power in January 1986, once said that leaders who overstayed were the root of Africa's problems.
Yet, while running in the 2016 poll, he said it was not the right time for him to leave because he still had work to do.
His government deals with the opposition ruthlessly with leaders facing harassment and physical assaults by security agencies.