Rajapaksa signed the papers ordering for the release of Fonseka prior to his departure to Qatar, presidential spokesman Bandula Jayasekera told reporters in Colombo.
The papers were handed over to presidential chief of staff Gamini Senarath for onward transmission to the ministry of justice on Monday, following which the formalities for Fonseka's release would be completed.
Rajapaksa left on Saturday night on a state visit to Qatar.
Fonseka is currently serving a three-year jail term, having been convicted by the high court in what was termed as the 'white flag' case.
He was charged with causing public disaffection of the State through his statement that the senior defence establishment had ordered the killing of Liberation Tigers of Tamil Eelam formers who had approached the army with white flags on the final day of the military clashes in May 2009.
Expectations for Fonseka's release had mounted when his wife Anoma said earlier this week that Rajapaksa had expressed a desire to grant him a presidential pardon.
Fonseka also received bail this week in the case where he was accused of harbouring military deserters.
As the military chief, Fonseka had led the Sri Lankan army to a crushing victory over the LTTE rebels in 2009. But he fell out with his commander-in-chief Rajapaksa immediately after the war ended.
Rajapaksa ordered Fonseka's detention almost immediately after he had crushed the former Army chief in the presidential election of 2010.