Juan Carlos left himself open to possible court action, including a paternity suit brought by a man claiming to be his son, when he gave up the throne last week after 39 years for his heir, King Felipe VI.
Now ruling party politicians have slipped in amendments to a pending judicial reform to assure Juan Carlos new judicial privileges as quickly as possible.
The ruling Popular Party which holds a majority in the parliament pushed them through despite reluctance from opposition lawmakers.
Under the new measures, only the highest court in the land, the Supreme Court, will be qualified to hear cases against Juan Carlos.
Also Read
They also extend the privilege to Spain's new queen, Felipe's wife Letizia, and his eight-year-old daughter and heir Leonor, Princess of Asturias.
The main opposition Socialist Party supports legal protections for the ex-king but abstained in Thursday's vote, complaining the law was being rushed through without a proper debate.
Juan Carlos's former constitutional immunity thwarted two lawsuits in October 2012 by people claiming he fathered them before becoming king. One of the plaintiffs, Albert Sola Jimenez, has an appeal pending.
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.
Juan Carlos's youngest daughter Cristina is facing fraud allegations that have damaged the monarchy's popularity. A judge had yesterday upheld those charges against her, meaning she may now be sent to trial.