Panda diplomacy: Merkel and Xi pushed into awkward embrace before G20

* Xi arrives in Berlin on Tuesday evening for Merkel meeting

* Visit comes days before Hamburg G20 in signal to Trump

* Berlin sees Beijing as ally on climate, trade, Africa

* Stressing harmony, leaders will welcome pandas, discuss soccer

By Noah Barkin

BERLIN, July 4 (Reuters) - When President Xi Jinping took the stage in Davos in January and painted China as a champion of free markets ready to fill the global leadership role vacated by the United States, German officials couldn't help but chuckle.

Their expectation was that Donald Trump, due to be inaugurated as U.S. president days later, would quickly temper his protectionist campaign rhetoric and patch up ties with Western allies, leaving little space for Beijing.

Six months later, as Xi arrives in Berlin for a highly symbolic visit with German Chancellor Angela Merkel before a Group of 20 summit in Hamburg, what seemed laughable in the thin mountain air of the Swiss Alps is not so absurd any more.

Despite concerns about human rights in China, frustrations over market access and worries about a wave of corporate takeovers in Europe by state-run Chinese firms, Germany is being pushed into an awkward embrace with Beijing as Trump doubles down on his promise to put "America First".

For Merkel, the G20 host, Xi is an ally and Trump a troublesome rival on some of the most important issues on the agenda in Hamburg - from trade and climate change to economic development in Africa.

And so, Merkel will dine with Xi on Tuesday and plot G20 strategy with him over lunch on Wednesday.

After that, the two leaders will indulge in classic "panda diplomacy", opening a $10 million Chinese compound in Berlin Zoo for Meng Meng and Jiao Qing - two giant pandas that China is lending to Germany as a token of friendship.

"For Beijing, the goal is to present itself as a generous, cooperative and friendly power, at home and abroad," said Sebastian Heilmann, director of the Mercator Institute for Chinese Studies (MERICS) in Berlin. "It also serves to distract from politically controversial topics."

BIG POWER TENSIONS

The visit, a month after Chinese Premier Li Keqiang travelled to Berlin to meet Merkel, comes at an extremely sensitive time for big-power relations.

Trump is ratcheting up pressure on Beijing to restrain North Korea, which on Tuesday announced that it had successfully test-launched an intercontinental ballistic missile that showed it could strike anywhere in the world.

His administration is threatening punitive trade measures against China on steel, a step that could also hit German exporters. Meanwhile a U.S. warship sailed near a disputed island in the South China Sea on Sunday, prompting Beijing to complain of a "serious political and military provocation".