Rajab, who heads the Bahrain Centre for Human Rights (BCHR), was convicted in 2012 of taking part in illegal gatherings and disturbing public order.
An appeals court later reduced his original three-year term by a year.
He was one of several leading activists arrested by the authorities after pro-democracy protests erupted in 2011.
Soon after his release on Saturday, Rajab told the Associated Press news agency that he was happy to be out after spending more than 600 days in prison.
He also appealed for the release of all political prisoners, the agency added.
Rights groups, including Amnesty International and Human Rights First, have campaigned on behalf of Rajab throughout his prison sentence, calling on the authorities to release him.
In December 2013, a Bahraini court rejected a request by Rajab's lawyers for early release. They argued that he was eligible because he had already served three-quarters of a two-year sentence.
In addition to his role with the BCHR, Mr Rajab is deputy secretary general of the International Federation for Human Rights (FIDH).
Before his imprisonment in July 2012, Mr Rajab was repeatedly detained in connection with the pro-democracy protests that erupted in the Gulf kingdom the previous year.
Amnesty said that he was punched in the face several times by riot police as he led a demonstration in February 2012, and in May 2012 was charged with "insulting a national institution" in comments about the interior ministry he posted on Twitter.
In June 2012, Rajab was sentenced to three months in jail over different tweets he wrote about the prime minister. The conviction was eventually overturned on appeal, but only after he had begun his two-year sentence for taking part in unauthorised protests.
At his trial, Mr Rajab told the court that he had been held in dire conditions and subjected to ill treatment, including being placed in solitary confinement with a dead animal and kept almost naked.
BCHR's founder, Abdulhadi al-Khawaja, is serving a life sentence for allegedly plotting to overthrow the government. He was convicted on evidence that was widely accepted as having been secured under torture.

Nottingham-born Fletcher, 41, began his broadcasting career in the city.
Sports PR firm founder Paul Mace, a lifelong Magpies fan, and property consultancy director Jon Enever have also joined the club.
Chief executive Jason Turner becomes football operations director, with Corrine Rigby as finance director and Amanda Fletcher as commercial director.
Chairman Alan Hardy said: "I am delighted to have put together such a strong team of people who have a diverse and complementary range of football and business skill sets.
"Football is a team game and it is important that we have a committed, enthusiastic and experienced senior group in place dedicated to getting Notts County back to where they belong in the English footballing pyramid."
Enever is a board member of Nottingham Means Business and chairman of Talented Enterprising Nottingham, while Mace wrote the 250,000-word Notts book One Flew Over The Magpies Nest.
Turner arrived at Meadow Lane in April 2016 after previously holding similar positions with Newport County, Plymouth and Cardiff City, while Rigby and Fletcher were both executive appointments by Hardy when he took over the club in January.
Prominent Bahraini human rights activist Nabeel Rajab has been freed after serving two years in prison for his involvement in illegal protests.
[NEXT_CONCEPT]
BBC Radio 5 live presenter Darren Fletcher is one of six appointments to Notts County's new board of directors.