A Romanian immigrant has been elected mayor of a town in eastern Germany after three parties joined forces to beat the Alternative für Deutschland (AfD) candidate and film industry luminaries campaigned against the far-right party.

Octavian Ursu of the CDU was elected as Görlitz’s mayor at the weekend following a tight second-round run-off in which the AfD candidate was defeated only after the Greens and the Left party agreed to withdraw their candidates and unite in their support for Ursu.

The AfD had been on course to win its first mayoralty after its candidate, Sebastian Wippel, a former police officer, won the first round of the vote on 26 May, with 36.4%, six points ahead of Ursu.

Ursu, a trained classical trumpeter, secured 55% of the vote on Sunday, 10 points ahead of Wippel.

Actors, directors and others who made films on location in Görlitz had called on residents to vote against Wippel. The petition urged voters not to succumb to “hate and enmity, discord and exclusion”.

It was signed by the British director Stephen Daldry, who filmed The Reader partly in Görlitz; the actor Daniel Brühl, who appeared in Goodbye Lenin; and the writer Bernhard Schlink, among others, according to France 24. AfD condemned the letter as unwelcome outside advice.

Sebastian Wippel reacts after the announcement of his defeat in the mayoral election in Görlitz. Photograph: Matthias Rietschel/Reuters

Annegret Kramp-Karrenbauer, the national head of the Christian Democrats (CDU), who is positioning herself to replace Angela Merkel as chancellor, was criticised for trying to claim his win as a victory for the CDU and failing to acknowledge the contributions of the other parties.

“Octavian Ursu and the CDU in Saxony have shown in Görlitz that the CDU is the civic power against the AfD,” she tweeted.

She was met by a storm of protest from across the parties, in particular those which had united to stop Wippel. Erik Marquardt of the Greens, which withdrew its candidate who secured 28% after the first round, responded on Twitter: “Before you get round to thanking the leftwing parties for enabling this victory, there’ll probably be no more ice left in Greenland, will there?”

Two hours later, Kramp-Karrenbauer was forced to effectively retract her previous statement, writing: “Octavian Ursu’s victory is the victory of a broad alliance for which I am grateful.”

It is the latest in a series of gaffes for which Kramp-Karrenbauer has been pilloried.

Ursu has pledged to reach out to voters who did not vote for him. “Now we have to see about getting close to those who didn’t choose me,” he said. Wippel, meanwhile, has claimed his result of almost 45% as a significant and respectable standing for the AfD, “considering that all the other parties mobilised their forces against us”.

Görlitz, on the German-Polish border, has built a reputation as Germany’s Hollywood – or Görliwood as it is nicknamed – due to its picturesque city landscape that unlike most German cities was largely undamaged during the second world war. The Grand Budapest Hotel and Inglourious Basterds are among the films shot in Görlitz.

A view of historical city centre of Görlitz. Photograph: Filip Singer/EPA

The city attracts more than 300,000 tourists every year, drawn by its late-gothic and early Renaissance architecture as well as the many film locations, mostly in its old town. But tens of thousands of mainly young residents have left over the past three decades, driven largely by a high unemployment rate. It has become instead a magnet for pensioners from western Germany attracted by its relative cheapness and picturesque qualities.

The vote has been seen as a bellwether for how well the AfD may perform in September’s state elections in the former communist east, including in Saxony, where Görlitz is situated. Polls show the AfD is due to make strong gains in both Saxony and Brandenburg, as well as in Thuringia, which goes to the polls a little over a month later.

The conservative newspaper Die Welt said that at first glance Ursu’s success in Görlitz resembled something of a “small midsummer fairytale”. But it said instead it should be viewed as a warning. “The fact that Ursu’s opponent from the AfD secured almost 45% of the votes … shows that the party possesses a considerable strength, comparable to that of the established parties.

“Even the other candidates’ decision to withdraw and even the many appeals … including from Hollywood for people to please vote ‘correctly’, did not succeed in isolating and downgrading the AfD.”

The AfD’s leader, Jörg Meuthen, said Wippel’s result was proof “that there’s no holding back the AfD any more”.

The party has been the main opposition in government since 2017 and is represented in all 16 state legislatures.

Reuters and Agence France-Presse contributed to this report