At 11:20 p.m. Tuesday evening, the Senate voted, by majority decision, to approve the highly-contentious Strategic Services Agency (Amendment) Bill.
The government secured the support of two independent senators, Ian Roach and temporary member Justin Junkere.
All other independent senators, along with the Opposition bench, voted against the controversial legislation.
The 15 Government senators supported the measure.
The final vote was 17-12.
Independent Senator Sophia Chote S.C., was not in the chamber when the vote was taken.
But Chote had voted against the bill when it was earlier put to members.
Following the initial vote, the Opposition called for a division, which led to the matter being read a third time.
That meant that the Senate met as a committee and considered amendments.
A wad of amendments proposed by the Opposition and articulated by Senator Wade Mark was all rejected by Attorney General Faris Al Wari.
Senator President Christine Kangaloo declined to accept a few amendments for discussion, saying they fell outside of the scope of the legislation.
Mark said the amendments were aimed at protecting the rights of citizens, but Al Rawi said he did not have Cabinet approval to agree to the proposals.
He promised, however, to consider the measures in future related legislations.
The late evening vote followed a lengthy debate, in which government members endorsed the amendments to the substantive bill and opposition senators strongly criticising the measures.
The Opposition pressed for the bill to be considered by a special committee of the Senate, but this was turned down by Al Rawi.
There were criticisms and expressions of concern about the bill from several independent senators.
The bill was previously passed in the House of Representatives.
The next step is for the amended legislation to be assented to by President Anthony Carmona.