Attorney Telesforo Guerra said the judge notified him verbally of the ruling, but added that it might take a day for formal written notification to win McAfee's release, possibly as soon as Wednesday.
Judge Judith Secaida did not immediately return phone calls seeking to confirm the ruling.
Guerra said Secaida ruled that McAfee's detention was illegal, ordered him released, and gave him 10 days to put his immigration situation in order. It was not immediately clear if McAfee could get some kind of temporary or transit visa to allow him to leave Guatemala.
McAfee has said he wants to return to the United States with his 20-year-old Belizean girlfriend. Guerra said that would be his client's best option.
"For me, it's best that McAfee go to the United States, that's definitely the country where he will be safest," Guerra said. "In Guatemala, he runs the risk that anything could happen to him."
McAfee was detained last week for immigration violations after he sneaked into Guatemala from neighboring Belize. He had been on the lam for weeks before that, saying he donned disguises to avoid Belizean police who want to question him in the fatal shooting in November of another U.S. expatriate, Gregory Viant Faull.
The victim lived a couple of houses down from McAfee's compound on Ambergris Caye, an island off Belize's Caribbean coast. McAfee acknowledges that his dogs were bothersome and that Faull had complained about them, but denies killing Faull.
McAfee has said corrupt Belizean authorities are persecuting him, something officials in Belize deny. McAfee says he fears for his safety in Belize because he has sensitive information about official corruption and refused to donate to local politicians.
In a live-stream Internet broadcast Sunday from the Guatemalan detention center where he was put under the government order that he be returned to Belize, the 67-year-old McAfee said he wants to return to the United States and "settle down to whatever normal life" he can.
"I simply would like to live comfortably day by day, fish, swim, enjoy my declining years," he said.
McAfee is an acknowledged practical joker who has dabbled in yoga, ultra-light aircraft and the production of herbal medications. He has led an eccentric life since he sold his stake in the software company named after him in the early 1990s and moved to Belize about three years ago to lower his taxes.
He told The New York Times in 2009 that he had lost all but $4 million of his $100 million fortune in the U.S. financial crisis. However, a story on the Gizmodo website quoted him as describing that claim as "not very accurate at all."
Faull's family has said through a representative that McAfee's skillful courting of the media, including blog posts, email messages clandestine interviews, has obscured the point that McAfee should submit to police questioning.