Fifty-six MLAs voted in favour of the Special Advisers Bill and 28 voted against it, following a lengthy and heated debate on Monday.
Sinn Féin put forward a petition of concern but failed to gain the one signature they needed to block the bill from becoming law.
The SDLP, which found itself holding the balance of power, chose to abstain.
The bill was proposed by TUV leader Jim Allister following the appointment of Mary McArdle in 2011 as adviser to Sinn Féin Culture Minister Carál Ní Chuilín.
Ms McArdle had been convicted of involvement in the IRA murder of 22-year-old Mary Travers, the daughter of Resident Magistrate Tom Travers, almost 30 years ago.
She vacated the position in March last year following a campaign by the victim's sister, Ann Travers.
Mr Allister said the legislation should be known as "Ann's Law" in tribute to her.
"This House - this community - owes a tremendous debt to that lady, who spoke with such compelling candour, honesty and persistence on behalf of all innocent victims," he said.
"Never again, never again will such re-traumatising of a victim's family be permitted. This Bill, first and foremost, is about righting that wrong and about saying that never again should it happen to anyone else."
Sinn Féin and the SDLP had opposed the Private Member's Bill during its further consideration stage, after a number of proposed amendments were rejected.
Despite initial suggestions, the SDLP then announced they would not sign a petition of concern which would block the bill in Stormont, after meeting with Ms Travers in private.
Ann Travers said she is "so pleased" to see the changes go through.
She continued: "I loved my sister Mary who was beautiful, gifted, talented - didn't deserve to die the way that she did, but certainly didn't deserve to have her memory stamped on."
I am so pleased that I have done everything I have done
Unionist members of the Northern Ireland Assembly supported the bill, while 27 members of Sinn Féin and Stephen Agnew of the Green Party voted against it.
Sinn Fein's Daithi McKay drew accusations of filibustering as he delivered a two-hour speech branding the bill "discriminatory".
Speaking after it passed, the North Antrim MLA said: "The SDLP today were led away from the Good Friday Agreement and onto the ground of discrimination and inequality by rejectionist unionist Jim Allister.
"Sinn Féin will continue to oppose discrimination in employment and in every other aspect of the operation of government. We will never accept discrimination and inequality and the opposition to this Bill will continue in the time ahead."
The new law means one of the deputy First Minister Martin McGuinness' special advisers, Paul Kavanagh, is set to lose his job.
He served 14 years in jail for his part in an IRA bombing in England in 1981.
Earlier some victims of the Troubles travelled to Stormont to urge politicians to block the law, while others spoke out in support of it - demonstrating the divisiveness of the issue.
Jude Whyte, whose mother was killed in a UVF bomb attack in 1984, has said the bill is "discriminatory and elitist".
He said: "It's directed at a very small number of people who, overwhelmingly, although I don't know any of these people individually, I do believe they have been working for the peace process for the last 30 years."
But later Serena Hamilton, whose off-duty soldier father David Graham was shot dead by the IRA in Co Tyrone in 1977, backed the bill.
She said: "They should not have high-powered jobs. My father is lying six foot under and has been for 36 years, and we have lost out in every aspect of life. They have got a high-powered job, they are being glorified and they are being rewarded for what they have done."
I would like to think that this House could go further than the debate on this bill to deliver an equal, ethical plan for dealing with our past
Campaigners representing families bereaved as a result of state actions said they felt let down by the SDLP, and some challenged the party's Foyle MLA Colm Eastwood.
Explaining the SDLP's stance, MLA Dominic Bradley said there were "flaws" in the bill and the only approach they could take was to abstain.
He said: "We think that it is flawed but in a situation where victims are being so sadly neglected for political reasons, the lesser evil in this case is to abstain and I believe that is an honourable position and indeed it is an ethical position."
Meanwhile Unionist politicians welcomed the passing of the bill.
UUP leader Mike Nesbitt said: "I pay tribute to the focus, determination and courage of Ann Travers in the face of despicable abuse from some sections of Irish Republicanism.
"She was determined that the memory of her sister Mary and others would live on. She has ensured that the voices of innocent victims will not be silenced."
Alastair Ross of the DUP said: "It's a victory for victims and a victory for Ann Travers.
"Unionists worked together on this issue and that's good, it's an example of cooperation in the Assembly and we were pleased as a party to be able to back it through its passage and ultimately see it into law."