By Daniel Wallis and Girish Gupta

CARACAS (Reuters) - Venezuela deported a U.S. filmmaker who had been arrested in April on accusations he was working as a spy for Washington and advising opposition student groups on how to destabilize the South American OPEC nation.

"The gringo Timothy Hallet Tracy, who was captured while spying in our country, has been expelled," Interior and Justice Minister Miguel Rodriguez Torres said on Twitter on Wednesday.

Tracy's lawyer, Daniel Rosales, said the charges against his client had been dropped, and that the 35-year-old filmmaker was put on a flight to Miami.

The outcome of his case has been seen as a test of new Venezuelan President Nicolas Maduro's intentions toward Washington following years of hostility from his predecessor, the late socialist leader Hugo Chavez.

President Barack Obama had said the accusations against Tracy were "ridiculous."

Friends and relatives of Tracy, who was a director and producer at Los Angeles-based Freehold Productions, according to his LinkedIn profile, said he was making a documentary in Venezuela ahead of its April 14 presidential election.

He was arrested 10 days after the vote as he tried to fly out of the country - amid a flurry of headline-grabbing accusations by the government that included a claim Washington was plotting to assassinate Maduro.

Venezuelan authorities said intelligence agents had been tracking Tracy since late 2012 and had uncovered ample evidence that he was plotting with militant anti-government groups to provoke "civil war."

KERRY TO MEET VENEZUELA'S JAUA

Rosales said the filmmaker had been treated well during his time behind bars.

"Everything worked out well in the end," the lawyer said.

Several dozen Venezuelan filmmakers had appealed for Tracy's release. According to his LinkedIn profile, Tracy attended Georgetown University and his work included the "Madhouse" TV series about stock car racing for the History Channel.

Obama's comments on Tracy's arrest, made during a trip to Latin America in early May, had infuriated Venezuela's government and revived accusations of "imperialist meddling" that became routine during Chavez's polarizing 14-year rule.

Maduro rebuffed Obama, describing his U.S. counterpart as "the grand chief of devils" and issuing a formal protest note.

Maduro, who narrowly won April's vote amid allegations of foul play by both sides, has at times also seemed to strike a more conciliatory note.

Venezuelan Foreign Minister Elias Jaua is due to meet U.S. Secretary of State John Kerry on Wednesday on the sidelines of an Organization of American States meeting in Guatemala.

Washington has held back recognition of Maduro, and a U.S. official said this week that there remained concerns about how deep post-election divisions in Venezuela would be resolved.

Maduro, a 50-year-old former bus driver who rose to be Chavez's foreign minister and vice president, said Jaua would make Caracas' position on relations with the U.S. government clear when he meets Kerry.

"There will be differences, but there must be respect," he said. "We have extraordinary relations with the whole world, and we can have good relations with the United States."

(Additional reporting by Marianna Parraga; Editing by Philip Barbara)