The European Parliament and EU member states struck an agreement on Friday on new rules to better protect media from interference and safeguard journalists' freedom.

"The agreement reached... is a testament to our commitment to fostering free and pluralistic media. For the first time, there will be safeguards in European law," German EU lawmaker Sabine Verheyen, who spearheaded the text through parliament, said.

The EU's Media Freedom Act was proposed by Brussels last year in the face of increased pressure facing journalists in countries such as Hungary and Poland.

Media activists had criticised EU states, led by France, for pushing to expand loopholes to allow authorities to spy on journalists in the name of "national security" during negotiations.

But Romanian MEP Ramona Strugariu said there was no reference to the controversial issue.

"There is no mention whatsoever of national security in any part of this legislative text. Nothing," Strugariu, leading the text through parliament, said.

Verheyen said any surveillance, such as the use of spyware in journalists' devices, would only be possible if there was a judicial decision and for serious crimes only.

"Not just for everything they can call national security," she said.

Vera Jourova, vice president of the European Commission for values and transparency, said the EU was "not regulating the media, we are regulating the space for media".

The draft text will become law once formally adopted by the parliament and member states.

EU countries can introduce stricter or more detailed rules than those in the law.

"Today's agreement confirms the EU's position as a world leader in protecting journalists, guaranteeing the independence of media providers, and ensuring that citizens have access to a wide and diverse range of reliable news sources," said Ernest Urtasun, Spanish culture minister.