Sukma Darmawan was to have stood trial for a second time on Monday, charged with "allowing" Anwar to sodomise him, but the judge acquitted and discharged him after the prosecutor told the court there was no evidence to support the charge.
Gobind Singh Deo, Sukma's lawyer, said: "What we have witnessed is a victory for judicial independence and even prosecutorial independence in this country."
Sukma was jailed in 1998 for sodomy after making what he said was a forced confession.
Prosecutors later used Sukma's admission to convict Anwar, who spent more than five years in jail on corruption and sodomy charges before being freed in 2004.
Anwar denied all the charges, saying they were contrived to end his career after he led anti-government protests after falling out with Mahathir Mohamad, the then prime minister, over Mahathir's handling of the 1997-98 Asian financial crisis.
Within a year of Mahathir retiring, the high court quashed Anwar's conviction.
"It's been a terrible time. It's been almost nine years, so at last I have freedom."
Sukma Darmawan after sodomy charges against him were dropped
Sukma appealed and was released on bail while he waited for the outcome.
In June this year, the court of appeal overturned his conviction and ordered the case to be retried.
"It's great, great," Sukma told Reuters news agency by phone. "It's been a terrible time. It's been almost nine years, so at last I have freedom."
Sukma said he made a false confession after police sexually abused him and threatened to have him shot.
He said the authorities offered him leniency if he falsely accused Anwar.
Gobind said the prosecution had told the court it was dropping the charge partly because of the age of the case and the fact that Sukma had already spent time in jail.