Cologne (Germany) (AFP) - Thousands of demonstrators hit the streets of Cologne Saturday as Turkish President Recep Tayyip Erdogan opened one of Europe's largest mosques at the end of his visit to Germany, with police out in force to manage rival rallies.

The inauguration capped a controversial three-day state visit aimed at repairing frayed ties with Berlin after two years of tensions.

During his stay in Berlin, Erdogan met twice with Angela Merkel for talks, with both leaders signalling their interest in a cautious rapprochement.

But the German chancellor stressed that "deep differences" remained on civil rights and other issues.

Before returning home, Erdogan travelled to the western city of Cologne where several thousand critics turned out to protest everything from Turkey's record on human rights and press freedom to its treatment of minority Kurds.

At one of the rallies on the bank of the Rhine, demonstrators waved banners reading: "Erdogan not welcome".

Cansu, a 30-year-old student of Turkish origin, came from Switzerland to join the protest.

"I want to be the voice of people who can't take to the streets in Turkey. Because they have been arrested, killed or otherwise suppressed," she told AFP.

"Erdogan thinks anything that differs from his opinion is terrorism."

- Thousands of supporters -

Erdogan supporters meanwhile gathered near the Cologne Central Mosque, an imposing dome-shaped building commissioned by the shadowy, Turkish-controlled Ditib organisation.

Cologne police cordoned off a large area around the mosque for safety reasons, but thousands of Erdogan supporters spilled into the side streets, hoping for a glimpse of the Turkish leader.

Many waved Turkey's red and white flag or held up pictures of Erdogan, with crowds cheerfully breaking into regular chants of the president's name or shouting "Who is the greatest? Turkey".

"Erdogan is very popular because he has done a lot for his people," said Yusuf Simsek, 42, a computer technician with Turkish roots.

Story continues

Both Cologne mayor Henriette Reker and the state's premier Armin Laschet declined to attend the mosque ceremony.

The snubs echoed the lukewarm welcome the Turkish leader received at a state dinner on Friday evening hosted by German President Frank-Walter Steinmeier, which several opposition politicians boycotted. Merkel also skipped the banquet.

- Conciliatory noises -

Ties between the two NATO countries soured after Berlin criticised Ankara's crackdown on opponents following a failed 2016 coup, which saw tens of thousands arrested.

Tensions eased somewhat after several high-profile German-Turkish nationals were released this year, but five remain behind bars.

Merkel, whose country is home to more than three million ethnic Turks, stressed the need for continued dialogue to overcome disagreements.

But she also highlighted Germany's interest in a "stable" Turkey, which she relies on to help stem the flow of migrants to Europe.

Erdogan, seeking international allies as he spars with US President Donald Trump and the Turkish economy is in turmoil, likewise struck a conciliatory tone.

In his speech at the mosque inauguration, he said his visit to Germany had been "successful" and strengthened German-Turkish ties at "a critical period".

But he again lashed Germany for not taking stronger action against "terrorists" like supporters of the Kurdistan Workers' Party (PKK) or followers of Muslim cleric Fethullah Gulen, whom he blames for the coup attempt.

He also said he wished Germans had shown more support for Turkish-origin footballer Mesut Ozil, who recently quit the Germany team over perceived racism and discrimination.

- Mosque controversy -

Cologne is located in North Rhine-Westphalia state which is home to significant numbers of ethnic Turks, many of whom moved to Germany as so-called "guest workers" from the 1960s.

The giant Cologne Central Mosque opened its doors in 2017 after eight years of construction and budget overruns, but had yet to be formally inaugurated.

The size of the building, designed to resemble a flower bud opening, and its two towering minarets has left some locals disgruntled, triggering occasional protests.

The Turkish-Islamic Union of the Institute for Religion (Ditib) that commissioned the glass and cement structure is itself not without controversy.

The group runs hundreds of mosques across Germany with imams paid by the Turkish state.

Known for its close ties to Ankara, it has increasingly come under scrutiny with some of its members suspected of spying on Turkish dissidents living in Germany.