Mr Museveni snubbed Uganda's first pre-election debate last month, saying such events were for schoolchildren.
The Ugandan leader, 71, is seeking to extend his 30-year rule by winning a fifth term in government.
The focus of the second debate was foreign policy and national security - considered to be Mr Museveni's strongest points.
The first debate focused on domestic issues such as health and education.
Most observers thought Mr Museveni maintained his composure and made concise points, the BBC's Catherine Byaruhanga reports from Kampala.
However, the moderators were less challenging in this debate. Some analysts wonder whether this was one of Mr Museveni's conditions for attending, our correspondent adds.
Mr Museveni said his rivals' allegations of corruption were fiction and also dismissed criticism of his economic policies and the state of the health care system.
Eight presidential candidates are contesting Thursday's polls. Ugandans will vote in parliamentary and local elections on the same day.
For the first time, Mr Museveni and his National Resistance Movement will face two strong opponents.
They are Kizza Besigye, the veteran opposition leader, and Amama Mbabazi, a former prime minister and close ally of the president.
Mr Besigya leads the Forum for Democratic Change, while Mr Mbabazi is running as an independent with the GoForward pressure group.
Major issues for voters include persistently high unemployment, corruption and the quality of public services.
Ugandan President Yoweri Museveni has taken part in his first televised debate ahead of elections on Thursday.