Leading European nations have signed an agreement to advance the fight against terrorism with tough measures aimed at halting the exodus of young Europeans to fight for the Islamic State and other extremist groups.

Seventeen countries, including Britain, France, Germany, Italy and Spain, agreed on Thursday to the measures in the Council of Europe's 2005 Warsaw convention on preventing terrorism in the Latvian capital, Riga.

The pact specifically targets preventing the flow of "foreign terrorist fighters" to countries such as Syria and Iraq, amid concerns about what they might do upon return, by criminalizing participation in terrorist groups, training for terrorism or traveling abroad for terror funding.

The nations also agreed to set up a network of contacts "for rapid exchange of information."