The European Union has approved a scheme to share airline passenger information that can be used to track foreign fighters heading to and from conflict areas such as Syria and Iraq.

Politicians endorsed the Passenger Name Record law in a series of votes in Strasbourg, ending years of wrangling over how to balance security needs and privacy rights.

Under the scheme, traveller details will be collected from flights entering or leaving the EU and from flights between member countries. The information will be kept for six months.

"This is an important tool in the fight against terror," said Ivo Belet, a member of parliament for the EPP Christian Democrat group, the biggest in the legislature.

At least 5,000 Europeans are believed to have trained or fought in Syria and Iraq but authorities are struggling to track their movements and prove their activities.

The EU already has passenger data deals with the US, Canada and Australia.

The need for the legislation became ever more pressing in the wake of the November 13 attacks in Paris that killed 130 and last month's suicide bombings in Brussels, which left 32 dead.

France immediately welcomed the approval.

Interior Minister Bernard Cazeneuve said it would "enhance the security of EU citizens by allowing upstream tracking of jihadist terrorist movements".

He added it "will also be a step forward in the sharing of information between police forces and European intelligence, one of the crucial requirements to enhance our protection against a new and mobile terrorist threat".

The vote brought to an end a process that began eight years ago, delays that often drew public outcries as fears grew of extremist violence in Europe.

The agreement would give law enforcement agencies in the 28 EU nations access to information gathered by airlines, including names, travel dates, itineraries, and credit card and contact details.