The High Court in has ruled that prisoners and citizens in the diaspora should be allowed to participate in elections.
Lawyer Stephen Kalali filed the petition two years ago and the ruling was delivered on Wednesday.
He argued that excluding these two groups was a violation of their fundamental rights.
The electoral commission had argued that there was no legal framework which provided for voting while in the diaspora and in places of confinement.
The judge however said that by excluding these categories of people from voting, the Electoral Commission was acting contrary to the fundamental rights and freedoms in the constitution.
Uganda is due to hold a general election in 2021.
The coronavirus pandemic has already heavily affected the preparation for that election, with mass rallies banned.