The 83-year-old Cosby walked out of the State Correctional Institution Phoenix in Montgomery County, Pennsylvania, Wednesday afternoon, officials told ABC News.
Cosby's publicist, Andrew Wyatt, told ABC News earlier Wednesday that he was going to pick Cosby up at the prison.
Aerial footage from Philadelphia ABC station WPVI showed Cosby getting out of a car at his Elkins Park, Pennsylvania, mansion wearing a maroon T-shirt and baggy trousers. He flashed a peace sign as people helped him walk into his home.
Cosby later emerged from his home and walked to the end of his driveway where he stood with Wyatt and his lawyers as they addressed the media. Cosby smiled as reporters asked him to respond to no longer being incarcerated, but he declined to speak.
"What we saw today was justice, justice for all Americans," Wyatt said.
The actor released a statement on Twitter, writing, "I have never changed my stance nor my story. I have always maintained my innocence. Thank you to all my fans, supporters and friends who stood by me through this ordeal. Special thanks to the Pennsylvania Supreme Court for upholding the rule of law."
One of Cosby's appellate attorneys, Jennifer Bonjean, said she and the rest of Cosby's legal team were "thrilled" to have him home.
"He served three years of an unjust sentence. He did it with dignity, principle and he was a mentor to other inmates," Bonjean said. "He was really, as I say, doing the time. The time was not doing him."
She also thanked the state Supreme Court for demonstrating "they were impervious to the court of public opinion, which frankly the lower courts were not."
Cosby was sentenced in September 2018 to three to 10 years in state prison for allegedly drugging and sexually assaulting former Temple University employee Andrea Constand in 2004. Cosby served about three years of his sentence.
"Today’s majority decision regarding Bill Cosby is not only disappointing but of concern in that it may discourage those who seek justice for sexual assault in the criminal justice system from reporting or participating in the prosecution of the assailant or may force a victim to choose between filing either a criminal or civil action," Constand and her lawyers said in a statement.
In a ruling released Wednesday, the state Supreme Court concluded that Cosby's prosecution should never have occurred due to a deal the comedian cut with former Montgomery County prosecutor Bruce Castor, who agreed not to criminally prosecute Cosby if he gave a deposition in a civil case brought against him by Constand.
During that deposition, Cosby made incriminating statements that Castor's successor, Kevin R. Steele, used to charge Cosby in 2015.
Constand said in her statement that the decision to overturn the conviction resulted from "a procedural technicality."
Castor is the same lawyer who went on to represent former President Donald Trump during the ex-president's second impeachment trial earlier this year.
"The discretion vested in our Commonwealth's prosecutors, however vast, does not mean that its exercise is free of the constraints of due process," the Pennsylvania Supreme Court justices wrote in their 79-page decision.
"When an unconditional charging decision is made publicly and with the intent to induce action and reliance by the defendant, and when the defendant does so to his detriment (and in some instances upon the advice of counsel), denying the defendant the benefit of that decision is an affront to fundamental fairness, particularly when it results in a criminal prosecution that was foregone for more than a decade," the justices wrote.
The decision went on to say Cosby was the victim of an unconstitutional "coercive bait-and-switch."
Believing he had immunity from criminal prosecution, Cosby testified during four days of depositions by Constand's attorneys, and the civil lawsuit was settled for more than $3 million in 2006.
"As a practical matter, the moment that Cosby was charged criminally, he was harmed: all that he had forfeited earlier, and the consequences of that forfeiture in the civil case, were for naught," the justices wrote.
Cosby cannot be retried on the criminal charges.
"He was found guilty by a jury and now goes free on a procedural issue that is irrelevant to the facts of the crime," Steele said in a statement Wednesday afternoon.
Steele commended Constand "for her bravery in coming forward and remaining steadfast throughout this long ordeal, as well as all of the other women who have shared similar experiences."
"My hope is that this decision will not dampen the reporting of sexual assaults by victims," Steele said. "Prosecutors in my office will continue to follow the evidence wherever and to whomever it leads. We still believe that no one is above the law -- including those who are rich, famous and powerful."
In an interview with KYW Newsradio in Philadelphia, Castor said he was "not surprised" by the state Supreme Court's decision.
"I can only ever recall it happening once before in a case that the prosecutor's behavior was so egregious that the Supreme Court threw the case out and didn’t remand for a new trial," Castor told the radio station. "So it is rare, but what happened to Mr. Cosby was really egregious and what they did to him should never happen to any American citizen at any social strata."
Attorney Gloria Allred represented several women who testified at Cosby's trial to bolster the prosecution's evidence of "prior bad acts" against the entertainer and to prove a pattern of practice.
"Despite the Pennsylvania Supreme Court's decision, this was an important fight for justice," Allred told ABC News Live. "And even though the court overturned the conviction on technical grounds, it did not vindicate Bill Cosby's conduct and should not be interpreted as a statement or a finding that he did not engage in the acts of which he has been accused."
Janice Baker Kinney, one of the women who testified at Cosby's criminal trial alleging that he sexually assaulted her in 1982 when she was a 24-year-old bartender in Reno, Nevada, told ABC News Live on Wednesday she was "stunned" by the news.
"I'm shocked, and my stomach's kind of in a knot over this," Kinney said. "Just one little legalese can overturn this when so many people came forward, so many women have told their truths."
Another accuser, Victoria Valentino, a former Playboy model who didn't testify at the trial but claimed Cosby drugged and sexually assaulted her when she was a young woman, told ABC News that "my stomach is lurching" upon hearing Cosby would be released.
"I am deeply distressed about the injustice of the whole thing," Valentino said. "You know, he's a sociopath, he's a serial rapist."
She said Cosby's release came just days after she and the other Cosby accusers received a letter from Pennsylvania officials advising them that Cosby's request for parole was denied.
Cosby, who has maintained his innocence, had his petition for early parole denied in May after corrections officials cited his refusal to participate in prison sex offender programs.
In an appeal of the conviction, Cosby's lawyers argued that the trial judge erred in allowing Cosby's prior deposition about using quaaludes during consensual sexual encounters with women in the 1970s.
Two lower courts, including a three-judge panel of Pennsylvania Superior Court jurists, had previously refused to overturn the comedian's conviction.
Despite the deluge of accusations against him, Cosby has maintained he never engaged in nonconsensual sex.
ABC News' Meredith Deliso contributed to this report.