Yemen's parliament has voted to approve immunity from prosecution for President Ali Abdullah Saleh, who recently signed a deal to formally step down next month.
The issue has been one of the most sensitive in a complicated power transfer deal, with many protesters still demanding that he face trial.
The deal also gives partial immunity to some of Mr Saleh's aides.
Earlier drafts offered blanket immunity to anyone who had "worked with him".
Mr Saleh has ruled Yemen since 1978, where a year of political turmoil that has left hundreds dead.
Security forces controlled by the president and his family, as well as armed loyalists, have been accused of killing anti-government protesters.
The president handed over power to his deputy in November in return for immunity from prosecution.
The UN High Commissioner for Human Rights, Navi Pillay, has said granting immunity to those accused of gross human rights violations would break international law.
But those in favour of the deal say that immunity for Mr Saleh is necessary for Yemen to be able to move towards a democratic future.
The president only signed the power transfer deal after many false starts. Even after he did sign, uncertainty persisted over whether he would actually honour the deal.
One of the main issues was whether his key aides, including his sons, would also get immunity. The law just approved by Yemen's parliament does give them some legal protection, but not full immunity.
A BBC correspondent says the move seems bound to further inflame the hundreds of thousands of anti-Saleh protesters, who have continued to take to the streets demanding that the president be put on trial.