By Alastair Macdonald

BRUSSELS, Dec 4 (Reuters) - EU governments and the European Parliament drew years of wrangling over security forces' use of airline passenger data toward a close on Friday by agreeing to a compromise deal with the legislature.

The dispute over the retention and sharing of passenger name records -- PNR -- became a shibboleth in Brussels. As drafts were batted to and fro, PNR defined arguments between protecting people's privacy and protecting people from terrorism.

Islamist attacks in Paris this year, in January and last month, lent impetus to France and other governments to press the EU parliament to relent. German lawmakers in particular have been wary of mass data collection, recalling historic abuses and new revelations about U.S. surveillance. However, a new proposal from legislators this week won interior ministers' backing.

"The compromise agreed today will enable the EU to set up an effective PNR system which fully respects fundamental rights and freedoms," said Etienne Schneider, the Luxembourg minister who chaired the council of 28 governments in Brussels on Friday.

Timothy Kirkhope, the member of the European Parliament who has steered the legislation, said he would recommend its adoption in committee. The final step will be a plenary vote, though agreement among the main parties should limit surprises.

"This is a good agreement that will deliver an effective tool for fighting terrorism and serious crime," Kirkhope said. "This has always been a careful balancing act to ensure the system was proportionate to the risk that we face."

The deal foresees data being available to other countries' security agencies for six months and stored and available under stricter rules for a further 4-1/2 years. France wanted a year's easy availability and parliament just three months.

A French call for the rules to apply not only to flights to and from non-EU countries but to internal European Union flights was left in the deal as an option. But French Interior Minister Bernard Cazeneuve said he was satisfied, since all 28 states had pledged to implement the option of collecting internal flight data.

PNR includes name, travel dates, itinerary, ticket details, contact details, travel agent, means of payment, seat number and baggage information. Many police forces already collect it and many European states share it with each other and with countries outside Europe. But the lack of a common EU system, including data formats, has been seen as hampering European security. (Reporting by Alastair Macdonald; Editing by Ruth Pitchford; @macdonaldrtr)

Our Standards: The Thomson Reuters Trust Principles.