The law targets foreign as well as local media, and is seen in part as an effort to silence criticism of the scandal surrounding sovereign wealth fund 1MDB that has rocked the administration of Prime Minister Najib Razak.
The election is expected within weeks and Najib is battling to win a third term at the head of the coalition that has led Malaysia for over six decades.
The current parliament is dominated by the ruling Barisan Nasional (BN) coalition.
The law originally proposed a maximum prison sentence of 10 years and a fine of 500,000 ringgit ($130,000) for publishing what authorities deem to be fake news, but the government lowered the jail term to six years following a storm of criticism.
"This law is not intended to restrict the freedom of speech but to restrict the dissemination of fake news," said minister Azalina Othman Said.
But opposition legislators were not convinced, criticising the law's heavy penalties and its potential to limit free speech.
"This bill... is a weapon to close the truth so that what is false can be upheld as true, and what is true can be reversed as false," said Lim Guan Eng of the Democratic Action Party.
"This is something very dangerous for our country."
The law must still be debated in the senate but is expected to be passed. More than half of the senate is filled with Barisan Nasional members.
After this it needs royal assent before taking effect.
The new law has sparked widespread anger from activists, press freedom groups and the opposition, who believe it is aimed at cracking down on dissenting voices rather than safeguarding the public from false information.
Before it was passed, Brad Adams, Asia director at Human Rights Watch, condemned it as a "blatant attempt by the government to prevent any and all news that it doesn't like, whether about corruption or elections".
The law covers any information that is deemed to be "wholly or partly fake".
It includes several examples, such as a blogger publishing a report known to be false; someone sharing information on social media they know to be false; and someone giving a speech containing information they know to be untrue.
Malaysia is one of several countries in Asia turning to such legislation, emboldened by US President Donald Trump's fulminations against "fake news", but activists warn authoritarian regimes will use the laws to target opponents.
A parliamentary committee in neighbouring Singapore, which is examining possible legislation to combat "fake news", came under fire Monday from activists who alleged it misrepresented them.
Institute of Journalists Malaysia board member Ram Anand said the law, like existing legislation, would hang over journalists in the country and do "very little" to improve press freedom.
"We should be removing criminal laws that affect the media, not add more of them," he said.
Malaysia ranks 144th out of 180 countries in the 2017 World Press Freedom Index, with number one being the freest.
The law comes less than a week after parliament voted in favour of a move to redraw electoral borders. Opposition politicians said this would tilt the election in Najib's favour.
Najib is fighting to keep his coalition -- which has never lost a national poll -- in power while battling allegations that billions of dollars were looted from 1MDB, a sovereign wealth fund he founded.
Both Najib and the fund deny any wrongdoing.
He faces a tough challenge from an opposition led by his former boss and ex-premier Mahathir Mohamad, 92, who is looking to unseat him at the polls.
Get the latest election news, live updates and election schedule for Lok Sabha Elections 2019 on ndtv.com/elections. Like us on Facebook or follow us on Twitter and Instagram for updates from each of the 543 parliamentary seats for the 2019 Indian general elections.