Under the new law, Nasheed, 47, who was jailed for 13 years after being found guilty of terrorism charges, will lose his leadership and membership of the Maldivian Democratic Party (MDP).
The law was passed by 42 votes in favour, with just two against.
MDP MPs did not take part in the vote, but protested on the Majlis floor as deputy Speaker 'Reeko' Moosa Manik announced the vote, using megaphones and sirens to make his voice inaudible. The ruling Progressive Party of the Maldives has a strong majority in the parliament.
Nasheed remains the MDP's presidential candidate, the party has said, despite his jail sentence.
More From This Section
"The government, because they have absolute power, is trying to wipe out all political rivals. Note this, they will eventually try to disband the MDP. But how can they get rid of what is in our hearts?" Waheed said.
MDP MP Eva Abdulla said the party would not accept the government using the Majlis as "an extension of its tyranny to strip us of our democratic rights".
A court on March 13 convicted the former president under anti-terrorism law for arresting a senior judge illegally when he was president three years ago, saying the arrest was similar to abduction.
Nasheed, the first democratically-elected leader of the Indian Ocean archipelago, was arrested on February 22 over the detention of a judge in 2012.
He claimed that he was forced to quit after soldiers and police mutinied and overran his party's headquarters in the capital Male.
However his successor, Mohamed Waheed, who had been serving as vice-president, had said Nasheed left of his own accord.
Nasheed had taken refuge at the Indian High Commission in Male to avoid being arrested in connection with the same case in February 2013.
Nasheed had ended a 30-year autocratic rule by the current president's half-brother Maumoon Abdul Gayoom in 2008.