Sarath Fonseka, Sri Lanka's former army chief, has has been released from prison after President Mahinda Rajapaksa granted him a pardon to coincide with the third anniversary of the government's victory over Tamil separatists.
His freedom comes more than two years after he was jailed on corruption charges after an unsuccessful bid to unseat the president in 2010.
"I am free. I will devote my life for my people," Fonseka said on Monday as he emerged from Welikada prison in the capital, Colombo.
Fonseka was later stripped of his military rank but he is still revered by many as a hero for his role as a senior soldier in ending Sri Lanka's 25-year civil war against the Tamil Tiger rebels.
Rajapaksa was under international pressure to release his prominent rival.
Fonseka leads the Democratic National Alliance, which has seven seats in a 225-member legislature.
Some legislators from other opposition parties have said they are ready to back him due to his popularity and outspoken criticism against Rajapaksa.
He trailed Rajapaksa by 17 points in the last presidential election and, with the next one not due until 2016, he is not seen as an immediate political threat. His health has deteriorated in prison, increasing the pressure on Rajapaksa to release him.
Economic woes pushing up the cost of living have dented the government's popularity with local elections due later this year, and some analysts see Rajapaksa's decision to release his rival as a move to increase his party's chances by dividing the opposition.
Fonseka is being treated in hospital for respiratory problems arising from a 2006 assassination attempt by a Tamil suicide bomber.
His wife said she met Rajapaksa on Wednesday and he informed her of the pending release.
"The president said the general will be released unconditionally," Anoma Fonseka said. "The president told me that he will be releasing the general very soon and wanted the pending issues to be sorted out."
Fonseka and Rajapksa's brother, defence secretary Gotabaya Rajapaksa, led the army to victory in the final stages of the war, but they fell out after the war ended.
The general complained he was sidelined by the president, who grew concerned Fonseka was plotting a coup.
The career infantry officer was prosecuted for an interview he gave to the Sunday Leader newspaper in December 2009 in which he said he was informed that Gotabaya Rajapaksa ordered troops to kill surrendering rebel leaders.
A US-backed resolution at the UN Human Rights Council last month urged Sri Lanka to investigate alleged abuses during the last months of the war.
Rights groups say both the former army chief and the president are implicated in shooting fighters as they sought to surrender.
Source: Al Jazeera and agencies