Spain's royal palace has announced that King Juan Carlos and Queen Sofia will retain the title of king and queen after their son Felipe assumes the throne on Thursday.

A royal decree to be passed by the council of ministers on Wednesday will ensure that the royal couple maintain their immunity from civil or criminal prosecution.

Almost as soon as the king announced his abdication this month there was speculation as to whether the royals would retain their immunity. The government, caught off guard, began drawing up special legislation within 24 hours of the announcement.

Other members of the royal family do not have immunity and the king's youngest daughter, the Infanta Cristina, is being investigated on charges of tax fraud and money laundering relating to the business activities of her husband, Iñaki Urdangarin. Cristina has not been invited to her brother's investiture.

Last year two judges in Madrid threw out paternity cases brought against the king on the grounds that they pre-dated his reign and therefore he was "not subject to responsibility" under the constitution. Had he lost his immunity on stepping down from the throne, these cases could have been heard by ordinary courts.

There are no precedents in a case such as this because Spain has had only one king since it became a democracy in 1978. The dictator Francisco Franco appointed the then Prince Juan Carlos as his successor in 1969 and the new king swore his allegiance within the legal framework of the dictatorship, since overturned by the 1978 constitution.

Once Felipe is enthroned, Juan Carlos and Sofia will come after Felipe and his wife and children in the royal pecking order. Juan Carlos has said he is standing down because he does not want his son, who is 46, to "wither" like Prince Charles, who is 65. He has said he will not attend his son's investiture because he does not want to distract attention away from the newly crowned king.

After the ceremony on Thursday, King Felipe VI and Queen Letizia will tour central Madrid in a motor cavalcade – a somewhat risky venture given the strength of republican sentiment that has emerged since the abdication was announced.

Around 10,000 public figures including the prime minister and his cabinet, judges and public prosecutors enjoy immunity from the Spanish judicial system. Cases against them can only be brought before the supreme court.