The Senate has passed laws that amount to the most significant overhaul of Australia’s security and foreign interference laws in decades – creating new espionage offences, introducing tougher penalties on spies and establishing a register of foreign political agents.

The Senate passed the two bills on Thursday night, in the final hours before parliament rose for the winter break.

Earlier this month the attorney general, Christian Porter, insisted the laws needed to be passed urgently before the 28 July byelections, saying foreign agents were increasingly trying to cause chaos in democratic electoral processes and needed to be stopped.

He has said advice from the director general of Asio suggested efforts by foreign countries and foreign agencies to sway Australian opinion in a covert way to influence democratic outcomes was on the rise.

“So it makes complete sense to have these laws in place before the next large democratic event,” he told the ABC.

The espionage and foreign interference bill introduces new spying offences, updated sabotage offences and a new offence relating to the theft of trade secrets on behalf of a foreign government.

The foreign influence transparency scheme bill will create a register for individuals or entities undertaking activities on behalf of “foreign principals”.

Porter said on Thursday Australia’s national security had been greatly enhanced with the successful passage of the two bills, calling them “strong new laws against those who seek to undermine our national security and our democratic institutions and processes”.

“They are a critical tool for our national security agencies to use to counter the growing and ever-changing threat faced by Australia and other countries.

“We have heard time and time again from our most senior national security leaders that we live in a time of unprecedented foreign intelligence activity against Australia with more foreign agents, from more foreign powers, using more tradecraft to engage in espionage and foreign interference than at any time since the cold war.

“Even in the time taken to consider these bills the threat environment has changed and become more acute.”

This month Porter conceded that the foreign influence transparency scheme – which will force individuals acting on behalf of foreign powers to be listed on a public register – will not be in place before the July byelections even if the legislation passed parliament, but he said the bills were about more than the register.

“The bills are meant to work in tandem, so having both laws in place before the byelection is not only important in terms of signalling the seriousness with which we take any efforts to interfere but it also establishes, for the first time, a law, a criminal offence, against that interference,” he said.

The legislation was announced in December by the then attorney general, George Brandis.

The original bill risked sweeping whistleblowers, aid workers, journalists and other not-for-profit workers into its net through its wide-sweeping definitions, but the government and Labor insist amendments to the legislation have accounted for those concerns.