In what may be seen as a dramatic turnaround, President Museveni says he is ready to assent to the Anti-Homosexuality Bill, passed by Uganda's Parliament last December.
A State House statement released on Sunday said the president was convinced there was no scientific evidence that homosexuality was genetic or natural.
"There is no scientific proof yet that people are homosexuals by genetics," the statement quoted Mr Museveni as saying.
"It is on the strength of that I am going to sign the bill. I know we are going to have a big battle with the outside groups about this, but I will tell them what our scientists have to say."
Museveni was on Saturday evening speaking at the closure of the 3rd NRM caucus retreat at the National Leadership Institute in Kyankwanzi. He said he had not rushed to assent to the bill because he had to take all the precautions as he was directly answerable for whatever he does as a leader.
The president thanked participants at the retreat for their deliberations also announced that legislation on not granting of bail to all those who commit heinous crimes like murder, rape defilement and corruption will soon be tabled. He also said he would push for the control of fund-raising activities as well as that of money lenders describing the two as the centres of corruption.
Mr Museveni will have left Kyankwanzi a very satisfied man. The attendance at the ruling party MPs' caucus was particularly impressive, with just over 30 MPs skipping the event for various reasons.
Besides, the president's supporters in what has been becoming an increasingly restless ruling party pulled off a political coup. They passed a resolution that will isolate any party member dreaming of challenging Museveni for position of the party's flag bearer in the presidential elections in two year's time. That will open the way for Museveni to rule the country for 35 years.
Museveni's prime minister, Amama Mbabazi, was the obvious target of the Kyankwanzi resolution. Despite being loyal to the president over the years, Mbabazi was understood to be harbouring his own presidential ambitions, perhaps in the event that the ageing president retires soon.
But the president has recently reiterated that despite knocking on 70, he was still very mentally agile, and was "still around".
Mr Museveni's latest position on homosexuality will surprise many. He has previously complained bitterly after Parliament passed the bill. On Friday, The Observer published an eight-page angry letter Museveni wrote to Speaker Rebecca Kadaga and MPs after they passed the anti-gay bill, which he had since refused to sign.
In the letter, Museveni betrayed his conviction that homosexuality is a form of genetic disability for which people need help rather than jail. Much earlier, he had warned MPs against antagonising the international gay lobby, pointing out that its backers could gather as many as 300,000 people.
How many of you here, the president teased, can command a rally of 300,000 people?
After refusing to assent to the bill, the president asked Ugandan scientists to advise him on whether homosexuality was a natural or an acquired tendency. In their report, the scientists declared homosexuality all but acquired deviant behaviour. This position flies in the face of mainstream Western scientific research, of which the Ugandan scientists must be aware.
Still, for a president not known for basing his decisions on scientific as opposed to political considerations, it is not clear why his position has suddenly changed. His decision to believe Ugandan scientists as opposed to western scientists who regard homosexuality as natural is curious.
The Observer Editor Richard M Kavuma believes the president may have been guided by political calculations. Because he was keen to win over MPs on key issues such as denying suspects bail on certain offences, Kavuma said, the president may have decided to sign the popular bill as a concession.
"But it is also true that some of the president's people may challenge the legislation in court and given Uganda's largely progressive Constitution, they may get the bill declared unconstitutional," Kavuma said.
"That way the president comes out looking good to his anti-gay electorate, while the judges will take the flak from Uganda's generally Christian conservative population."
Kavuma added: "Because the law is likely to fail anyway, the president may have found the political cost of signing the bill to be much lower than that of maintaining his locally 'anti-people' stance. On the contrary, he will be praised across churches, shrines and mosques if he signs the bill."