Barrak, 61, walked free from Kuwait's central prison to a frenzied reception by relatives and supporters who broke through a security cordon and surrounded his vehicle.
The former lawmaker, who served six consecutive terms from 1999 to 2012, openly criticised the government upon his release.
"One day I said and I repeat: History will jail those who sent me to jail," Barrak, still wearing a beige prison uniform, shouted to the cheering crowd.
Hundreds of family members and supporters braved scorching heat and dusty winds and waited for more than three hours for Barrak's release outside the central jail, 25 kilometres (16 miles) southwest of Kuwait City.
The jubilant crowd sang and chanted slogans praising Barrak, hailing him as "the conscience of the people".
Barrak gave a brief speech before a long motorcade drove him to his residence, where more supporters were waiting.
In a defiant speech there, Barrak said he was not given a "fair trial" and denied he had insulted the ruler as he had only expressed his "political opinion".
He said the situation in the Gulf state has deteriorated with authorities issuing freedom-curbing laws, punishing political opponents and revoking their citizenships.
Signup to our newsletter and follow us on Facebook and Twitter!
"The only way to forge reforms is through an elected government with its leader winning through the ballot box," Barrak said.
Under Kuwait's political system, the prime minister has always been a senior member of the ruling family appointed by the emir regardless of the outcome of an election.
In February 2015, Barrak was sentenced to two years in jail for comments he made at a 2012 public rally which undermined the status of Emir Sheikh Sabah al-Ahmad Al-Sabah.
Barrak had been protesting against changes to the kingdom's electoral law which he argued would allow the authorities to manipulate election results.
He is the most senior, and the most popular, opposition leader to be jailed in an unprecedented crackdown on dissent in Kuwait.
Dozens of opposition activists are either in jail or are facing trial for insulting the emir, including via social media.
Barrak's release comes months after a majority of his partners in the opposition alliance ended a four-year boycott of general elections.
The alliance won about half of the 50 parliamentary seats in snap polls in November.
The oil-rich emirate is widely viewed as a pioneer in operating a parliamentary system among the Gulf monarchies.
The OPEC member state sits on about seven percent of global crude reserves and pumps around 2.8 million barrels of oil per day.