PANAMA CITY — Former President Ricardo Martinelli of Panama has been found not guilty of political espionage after he was accused of spying on 150 people, including politicians, union leaders and journalists during his administration, and a court ordered his release.

The verdict read on Friday by a tribunal judge said that prosecutors had “failed to prove” their theory and the accusations had raised “reasonable doubts.”

The judges also lifted a measure that had banned Mr. Martinelli’s leaving the country. The former president, who governed from 2009 to 2014, was granted house arrest in June, after he had spent a year in preventive detention in a Panamanian jail.

Mr. Martinelli was extradited from Miami to Panama in June 2018. He had been living in the United States since 2015.