Yemen has approved a bill to shield President Ali Abdullah Saleh from prosecution when he steps down from power after months of protests and their violent suppression by authorities.

Parliament passed the law Saturday, Reuters reported, after the cabinet approved it two weeks ago. It gives Saleh full immunity for the entire 33 years of his presidency, and cannot be cancelled or appealed against.

More from GlobalPost: Yemen's youth protesters lament their unfinished revolution

The bill was also due to grant immunity to a vast swathe of government officials for any role they may have played in the crackdown. The version passed today, however, was amended to limit immunity to "politically motivated" crimes committed whilst conducting official duties, with an exception for those considered "terrorist acts."

The last-minute amendments were submitted yesterday after public outcry over the proposal for blanket immunity, said Agence France Presse. According to the BBC, hundreds of thousands of anti-Saleh protesters have continued demonstrating to demand that the president face trial.

The bill was held up by weeks of wrangling between lawmakers over who would get immunity, and how much. Saleh's supporters in parliament refused to accept the nomination of Vice President Abd-Rabbu Mansour Hadi as a candidate in February's scheduled presidential elections until the law had been passed, reported CNN. Parliament duly backed his candidacy in today's session.

The immunity offer, brokered by Saudi Arabia and other Gulf states, was a key part of the transition deal Saleh agreed to in November, under which he has to leave office by February. Presidential elections are due by Feb. 21.

The US State Department backed the bill as a necessary measure to allow the country to "move forward towards a democratic future."

However, United Nations human rights commissioner Navi Pillay said amnesties for those accused of serious human rights abuses were banned by international law, and urged Yemen to bring the people responsible to justice.

A senior ruling party official, Mohammed al-Shayef, told The Associated Press today that Saleh would shortly leave Yemen for Oman, from whence he would head to the US for medical treatment. It is unclear where he will settle after the trip.

More from GlobalPost: Nobel Peace Prize winner calls for the West to get tough on Yemen's president