National Assembly speaker Henry Ramos Allup said the measure passed after a second round of debate, sparking opposition lawmaker chants of "Freedom!" even as the president's socialist party's minority lawmakers voiced disgust.
"This law is aimed at laying the foundations for national reconciliation," said lawmaker Delsa Solorzano, who sponsored the legislation.
The measure demands the release of some 76 political prisoners, and hundreds of people "persecuted and exiled" due to their opposition to the leftist government in power for the past 17 years, she said.
Maduro quickly took a combative stance, broadcasting a speech on national television while the debate was under way.
"You can be certain that that law will not be making it through here, sir. Laws that are out to benefit terrorists and criminals, they will not make it to enactment. No matter what you do," the president said.
Legal experts say the opposition faces an uphill battle for the legislation to take effect. The president can send it to the Supreme Court, which critics claim he has stacked with supporters.
The amnesty law comes two years after the arrest of opposition leader Leopoldo Lopez. He was sentenced to 14 years in jail in September for alleged incitement to violence against the government in 2014 demonstrations that claimed 43 lives.
Venezuela's opposition is counting on the power of the street to force the deeply unpopular Maduro to listen to calls for change, after it won a landslide victory in legislative elections last December only to see the courts hamstring its new authority.
Seventeen years into the socialist "revolution" launched by the president's late mentor Hugo Chavez, a punishing economic crisis has stoked outrage in the once-booming oil giant, where chronic shortages of basic goods, long lines and soaring prices have become the norm.
Protests have come against the backdrop of a deep economic morass exacerbated by the crash in the price of oil, which long funded Chavez and Maduro's lavish social spending.
Despite holding the world's largest crude reserves, Venezuela's economy contracted 5.7 percent last year, its second year of recession.
Political analysts say all the constitutional options to force Maduro from power face likely rejection by the Supreme Court or the National Electoral Council, which the opposition has also accused the president of packing with allies.
But the president can't ignore the voice of the people either, analysts say.