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.
Prominent Bahraini human rights activist Nabeel Rajab has been freed after serving two years in prison for his involvement in illegal protests.