Rwanda has pardoned more than 2,000 prisoners, including a top opposition figure.
Victoire Ingabire, of the FDU-Inkingi party, has been serving a 15-year jail term for threatening state security and “belittling” the 1994 genocide.
She has been a leading critic of President Paul Kagame and says her trial was politically motivated.
Mr Kagame has won praise for reforming Rwanda’s economy but has also been accused of human rights abuses.
He won re-election for a third time last year with 98.8% of the vote, in an election observers said was a sham.
In parliamentary elections earlier in September though, two opposition candidates from the Democratic Green Party won seats for the first time.
The release of Ms Ingabire and 2,140 other convicts was announced by the government following a cabinet meeting.
No reason was given for the move, but a statement said that Mr Kagame had exercised mercy under his prerogative as president.
Singer Kizito Mihigo was also freed, having been jailed for 10 years in 2015 for plotting to kill President Kagame.
Ms Ingabire smiled as she left jail, dressed in the colours of her party.
She thanked the president and said she hoped her release marked the opening of “political space” in Rwanda.
Justice Minister Johnston Businge sought to play down the significance of Ms Ingabire’s release.
“There is nothing political about her release – there is nothing political about her imprisonment,” he told Reuters.
Who is Victoire Ingabire?
Ms Ingabire returned from exile in the Netherlands in 2010 to take part in presidential elections.
She was arrested and barred from standing soon after, and has been in jail ever since.
Ms Ingabire, a member of the Hutu ethnic group, had questioned why Rwanda’s official memorial to the 1994 genocide did not include any Hutus.
Most of the 800,000 people killed were ethnic Tutsis but Hutu moderates were also slaughtered by the Hutu extremists.
Mr Kagame’s Tutsi-dominated Rwandan Patriotic Front put an end to the genocide.