Two police officers were injured and a car was set ablaze when violent protests broke out in Cologne, where the anti-immigration Alternative for Germany party (AfD) is holding a convention.

Up to 15,000 demonstrators and hard-left activists gathered in the city, with around 4,000 officers, many clad in riot gear or on horseback, deployed to prevent the escalation of anti-populist rallies.

Some 600 AfD delegates are meeting to discuss policy for September's national elections, but could only enter the convention centre under heavy police protection as protesters tried to keep them out.

Police escort an AfD delegate to the venue of the anti-immigration party's conference in Cologne (Reuters)

The two-day convention takes place days after AfD's co-leader Frauke Petry, Germany's best-known nationalist politician, said she will not be her party's top candidate in the general election – an apparent reflection of a growing split among leading party figures.

A spokesman for the Cologne police said the situation in the western German city was “very dynamic” and “fairly aggressive” in some areas.

He said police stopped about 100 protesters early on Saturday for identity checks, but they were not detained.

Broadcaster n-tv showed a group of around 50 people clashing with police on horses, and a television correspondent said police used pepper spray against some of the demonstrators.

The AfD, which rails against Chancellor Angela Merkel's decision to welcome over a million migrants over the past two years, is polling between eight to 10 percent support ahead of the election.

That is enough to give the party seats in parliament for the first time, but well below peak support seen in late 2016.

In her opening speech, before which she received a standing ovation from some party members, Ms Petry signalled she was willing to make compromises on her controversial motion for the party's future strategy.

Frauke Perry, co-leader of the nationalist AfD party, speaks during the conference (Associated Press)

Ms Petry has upset many within the party by introducing a motion in which she said the AfD should aim to join coalitions in future and govern, instead of being a “fundamental” opposition party that only made provocative statements.