Turkish President Tayyip Erdogan makes a speech during his meeting with mukhtars at the Presidential Palace in Ankara, Turkey, March 16, 2016. REUTERS/Umit Bektas ISTANBUL (Reuters) - Turkish President Tayyip Erdogan said on Friday Europe should look at its own record on migrants before telling Turkey what to do and accused it of "dancing in a minefield" by supporting terrorist groups.

In combative comments made as Prime Minister Ahmet Davutoglu meets European Union leaders in Brussels, Erdogan also said Turkey would only listen to external criticism on its rights record when it was justified.

"At a time when Turkey is hosting three million (migrants), those who are unable to find space for a handful of refugees, who in the middle of Europe keep these innocents in shameful conditions, must first to look at themselves," Erdogan said in a speech broadcast on television.

He accused some countries of directly or indirectly supporting terrorism, in apparent reference to the Kurdistan Workers Party (PKK) militant group which has waged a three-decade insurgency in Turkey's southeast. A PKK offshoot has claimed responsibility for two suicide bombings that killed 66 people in Ankara in the last month.

European leaders have expressed concern about the loss of civilian life in the southeast amid Turkey's military operations to flush out the PKK, urging it to use proportional force.

"Our struggle against terrorism is measured and legitimate ... Every terrorist organization active in our region and in Turkey has unified against Turkey. Many states, primarily Western countries, still cannot display a principled stance against these groups," he said.

He complained that Belgian authorities had allowed a pro-PKK tent to be put up outside the summit venue in Brussels, although he said its flag and posters had later been taken down.

European Union leaders are trying to convince Turkey's prime minister to help end Europe's migration crisis in return for financial and political concessions.

On Friday afternoon an agreement between the European Union and Turkey on curbing the flow of migrants into Europe was approved, Czech Prime Minister Bohuslav Sobotka said, according to Reuters.

(Reporting by Ayla Jean Yackley; Writing by Daren Butler; Editing by Nick Tattersall)