The bill secured the unanimous vote of the 242 lawmakers present, 14 more than the two-thirds majority it required. Lawmakers from religious parties and an opposition party led by former cricketer Imran Khan abstained.
The law is now expected to be passed by the upper house and signed into law by the president this week.
It will stay on the books for two years, allowing military courts to try anyone accused of terrorism offences.
Most politicians in Pakistan agree that military courts must be used to curb Taliban attacks because civilian courts are too cowed and corrupt to jail militants.
But some have raised concerns about the dramatic expansion of military powers in the coup-prone country.
The army is often accused of only targeting groups that stage attacks in Pakistan while tolerating others focused on neighbours India and Afghanistan.
The courts will have a limited mandate, Interior Minister Chaudhry Nisar Ali Khan said last week.
"Military courts will not be used against any politician, seminary, businessman, media person or common citizen," he said. "Nor is it a forum for dispensation of justice."
On Monday, the Pakistani Taliban leader Mullah Fazlullah released a video vowing more attacks on children. The government and the military say Pakistan's Taliban insurgency amounts to a war, so there is a precedent for the use of military courts.
"Spec courts not desire of the Army but need of extraordinary times," military spokesman Major General Asim Bajwa said in a message on social media website Twitter last week. "Will return to original system when normalcy returns."
Senator Afrasiab Khattak, a human rights activist, said he reluctantly supported the law.
"We have always stood for the independence of judiciary, but unfortunately they cannot deal with the hard-core terrorists," he said, citing attacks on judges and prosecutors.
He urged the government to strengthen the civilian judicial system. There is no full-time law minister, police are poorly trained and underfunded and witnesses and court officials receive no protection.
If the government had begun reforms of the civilian courts after its 2013 election, it would not have had to turn to the military now, the Dawn newspaper said in an editorial.
"Sadly, the political leadership has abdicated its responsibilities," it said.