The Senate on Tuesday voted 78-3 to pass the 28th Constitutional Amendment Bill with the required two-thirds majority.
The bill's passage by Senate was necessary for military courts to be accorded constitutional cover.
Voting on the bill had been put off last week for six days after the government failed to rope in a sufficient number of senators who could vote it into law.
At least 78 of the 104 members of Senate needed to vote in favour in order for the bill to pass with the required margin. The government managed to secure that exact number of votes, DawnNews reported.
The bill was expected to be opposed by five Jamiat Ulema-i-Islam-Fazl (JUI-F) senators, two Pakhtunkhwa Milli Awami Party senators, and one Balochistan National Party-Mengal senator.
The main opposition party, the PPP, is expected to have backed the government and voted in favour of the amendment.
When asked by reporters if he was concerned about his party's own coalition partner (JUI-F) voting against the bill, Law Minister Zahid Hamid had said: "We have the required 2/3 majority, so the bill should pass in Senate. No need to pursue others."