Turkey's president says his country has taught Europe and the world a lesson on humanity by hosting 2 million refugees from Syria and Iraq.

Recep Tayyip Erdogan on Sunday accused European nations of "confining refugees into the depth of the Mediterranean" in a reference to refugees who drown while trying to reach Europe.

He was speaking at a rally in Strasbourg, France, attended by hundreds of Turks, ahead of Turkey's Nov. 1 elections. The speech was televised live in Turkey.

Critics accuse Erdogan of organizing rallies in Turkey and Europe to drum up votes for the ruling Justice and Development Party, in breach of laws that require him to be neutral.

Erdogan is expected to address the migrant crisis with European Union officials in Brussels this week.