Sokha was released under conditions that he does not leave the country, does not engage in politics and must respond to any summons, Phnom Penh Municipal Court said in a statement.
He was arrested for treason on September 4, 2017 in a move widely seen as being politically motivated. After a year in pre-trial detention, he was released on bail last September and placed under house arrest.
Rainsy had long promised his return to Cambodia on Saturday, the country's Independence Day, but said he was denied boarding a Thai Airways flight from Paris to Bangkok on Thursday.
After his arrival in Kuala Lumpur on Saturday, MP Nurul Izzah invited Rainsy to a meeting in Malaysian parliament on Tuesday, but it is not known if he has accepted.
Cambodian authorities had on Saturday reinforced security along its border with military personnel, barbed wire and security controls.
Deputy Prime Minister Sar Kheng denied on Facebook that the opposition leader was not allowed to return, saying Rainsy and his colleagues may re-enter Cambodia but will face justice if they do so.