Singer David Mugema and music producer John Muwanguzi were accused of having composed and disseminated via the internet a tune titled "Wumula", meaning "retire", their lawyer Abdallah Kiwanuka told AFP.
Prosecutors said the song "attacked and disturbed the peace" of Museveni, Kiwanuka said.
A bill to remove presidential age limits was introduced in parliament in September, seen as paving the way for 73-year-old Museveni - who has been in power since 1986 - to run for a sixth term in office in 2021.
The current constitution blocks candidates over 75.
Although the song does not mention Museveni by name, the music video mixes pictures of the president alongside deposed leaders including Saddam Hussein of Iraq and Zimbabwe's Robert Mugabe.
"You must retire now," the song lyrics said. "Those who refused to go peacefully, where are they?"
The music video shows police breaking up protests.
"The doctors are striking over poor pay, the government says there is no money," the lyrics said. "But government never fails to get money to buy teargas."
The two musicians were released after each paying a cash bail of $550 and a bond of $2 750.