Under the changes green-lighted on Thursday, Juan Carlos will benefit from a legal shield which means he can only be tried in the Supreme Court — Spain's highest.
This spells an end to the legal uncertainty which confronted the former king after his recent abdication, a move which paved the way for his son Felipe to become the country's new monarch.
Also protected by the measure approved on Thursday — known as 'aforamiento' — are Juan Carlos's wife Sofia, Spain's new queen Letizia, and her daughter and heir to the throne Princess Leonor.
The parliament voted in the controversial measure despite opposition from the country's largest opposition party, the PSOE which argued the law should be debated in a full parliamentary session.
"The message this gives is: 'I am not citizen Juan Carlos... I am the most high king and the royal family only answers to the Supreme Court and God," said Gaspar Llamazares, leader of one of the opposition groupings, Plural Left recently.
Only the ruling Popular Party, the Navarrese People's Union (UPN) and the regionalist Asturias Forum approved the legal changes.
Juan Carlos's former constitutional immunity thwarted two legal suits in October 2012 by plaintiffs claiming to be his children, including Alberto Sola Jimenez, who was born in 1956.
It remains unclear whether the Supreme Court would hear a paternity suit such as Sola's or what other kinds of legal action the king might face.
A lower court is due to hear Sola's latest appeal on September 9th.
An estimated 10,000 Spanish members of parliament, judges, prosecutors and members of the government are afforded a special legal status for actions taken as part of their official duties.