WARSAW — The Polish government's hopes of scoring a diplomatic coup with Donald Trump's visit could backfire if the U.S. president goes ahead with plans to pay homage to the historic Solidarity leader Lech Wałęsa, who is reviled by the ruling Law and Justice party (PiS).

Nobel laureate and former President Wałęsa is an ardent critic of the PiS, which tries to depict him via pro-government media as a secret collaborator with the communist regime that he helped to bring down as leader of the Solidarity trade union protests in the 1980s.

Instead, the PiS wants to promote former President Lech Kaczyński — who died in an air crash in 2010 and was the twin brother of the powerful PiS leader Jarosław Kaczyński — as the most important and heroic figure in the struggle against the communists. Kaczyński himself doesn't mince words when referring to Wałęsa and once said of him in an interview: "big intellectual deficit, character faults and a horrible past" — the latter in reference to the allegation that Wałęsa was a secret service informer.

Glowing with pride at being the first major European capital besides Brussels to host an official visit by the U.S. president, Trump's hosts had hoped he would omit any mention of Wałęsa when he makes a speech in Warsaw Thursday, let alone meet with the 73-year-old former shipyard worker.

But American and Polish diplomats and officials, speaking on condition of anonymity, said the Americans had invited Wałęsa to the event and that Trump's speechwriters were currently amending his speech to include praise for the Nobel laureate and his service to Poland.

"Wałęsa will be present tomorrow when Trump delivers his speech in Warsaw. He will be sitting in the front row, among 12 leaders of the Three Seas Initiative,” Krzysztof Pusz, who runs a foundation set up by Wałęsa, told POLITICO. The Three Seas Initiative is a Polish-led regional forum of 12 EU countries that lie between the Baltic, Adriatic and Black Seas.

"Initially there was no plan for Trump’s meeting with Wałęsa, but the Americans concluded it should take place and they are still looking for a possibility to fit the meeting in the tight agenda,” said Pusz.

There had already been talk of Trump, who is an admirer of Wałęsa, inviting the former Polish president to visit him at the White House.

Wałęsa won admiration in America for a speech he delivered to the U.S. Congress in November 1989 just days after East Germans started to stream across the Berlin Wall and communism began collapsing all over the Soviet bloc. He started the speech with the words "We, the People!” — from the preamble to the Constitution of the United States — which prompted a long ovation.

When President George H.W. Bush visited Poland in 1989, shortly after the election that ejected the communists from power, he traveled to Wałęsa’s home city of Gdańsk to dine with him in his modest apartment. Since then, every U.S. president to visit Poland has met with Wałęsa.

Last year, Barack Obama used the occasion of a NATO summit in Warsaw to add his voice to Wałęsa’s criticisms of the PiS government for undermining democracy, which has pitted it against the European Commission and European Council (the latter headed by former Polish Prime Minister Donald Tusk). Wałęsa is planning to participate in a major anti-government protest in Warsaw next week, meaning more publicity and international media attention for the ex-president — the last thing the PiS wants.

CORRECTION: An earlier version of this article gave an erroneous attribution to Wałęsa’s speech in the U.S. Congress.