Clad in jeans and a blue shirt, and holding a small dog, Martinelli waved to reporters and talked with security agents outside the door of his home in Panama City in the morning.
Martinelli's defense had requested that he be freed on the grounds that Panamanian law says preventive detention cannot exceed one year.
The country's judicial branch said via Twitter that the court overseeing the case ordered "the cessation of the provisional detention of the ex-president of the Republic due to the one-year term being complete and imposes the measure of house arrest." The ruling does not halt his trial.
Martinelli, 67, was extradited from Miami to Panama on June 11, 2018, to face trial. Since then, he had been held at El Renancer prison and shuttled to court hearings under heavy police guard.
He is charged with spying on the communications of at least 150 people and of misusing public funds to purchase the equipment to carry out the intercepts during his 2009-2014 administration. Prosecutors are seeking a 21-year prison term.
Martinelli has said he is innocent.
Opposition politician Balbina Herrera, one of the subjects of the alleged illegal intercepts, said Wednesday's decision sets a bad precedent and noted that Martinelli had refused to face judicial authorities in the case before his arrest and extradition.
"In our opinion, yes there is a flight risk," Herrera told local TV.
Martinelli's defense said he was prohibited from using social media or talking to the press, his passport was confiscated and his house in an upscale neighborhood will be under guard.
"It is a step forward. We feel pleased," said Marta Linares, Martinelli's wife.
His lawyers were seeking for him to be allowed to move freely within Panama, and a court hearing was set for Friday to consider the appeals.
Associated Press writer Juan Zamorano contributed to this report.
Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.