By Noah Barkin and Richard Balmforth

BERLIN/KIEV (Reuters) - After months of ratcheting up pressure on Vladimir Putin, concern is mounting in Berlin and other European capitals that an emboldened Ukraine's military successes in the east are reducing the chances of a face-saving way out of the crisis for the Russian leader.

As a result, the focus of German-led diplomatic efforts has shifted, according to senior officials, towards urging restraint from Ukrainian President Petro Poroshenko and averting a humiliating defeat for pro-Russian rebels, a development that Berlin fears could elicit a strong response from Putin.

Chancellor Angela Merkel's planned visit to Kiev on Saturday, her first since the crisis erupted at the start of the year, is above all a signal of support for Poroshenko, the billionaire confectionary magnate who was elected less than three months ago.

But the German leader is also expected to use the trip to try to persuade Poroshenko, and nationalist hardliners in Ukraine who want to press their military advantage and crush the separatist rebellion in the east, to think hard about the consequences of such a course.

Central to Berlin's diplomatic offensive is the view that outright defeat for Putin's proxies in eastern Ukraine would provoke an unpredictable reaction from the Kremlin that could take the crisis to a dangerous new level.

"Poroshenko needs to know that there is understanding for how his government has acted but also that there can't be a military solution in the east," one official told Reuters on condition of anonymity. "He can't win with weapons. Putin won't allow this."

BATTLEFIELD REVERSAL

Germany has taken the lead in seeking a diplomatic solution to the crisis, with Merkel, a Russian-speaker who grew up behind the Iron Curtain in East Germany, talking to Putin more than any other Western leader.

The dynamics of their relationship took a turn for the worse back in March, according to German officials, when Putin was seen to have deceived the chancellor about his intentions in Crimea, and Merkel has since emerged as a driving force behind EU sanctions against Russia.

Story continues

Recent developments on the battlefield have flipped the logic of diplomacy in Ukraine on its head.

At the start of the conflict, Ukrainian forces were in disarray as rebels made lightning advances.

In the past few weeks, Ukrainian troops have taken the initiative. Dozens of settlements have been returned to Kiev's control, and Kiev's forces have all but encircled the cities of Donetsk and Luhansk, the main rebel strongholds.

Three senior separatist leaders have been replaced, and the rebels in Donetsk have introduced the death penalty for desertion and other infractions, in an effort to restore order in their own ranks.

The battlefield successes – as well as the heavy losses in fighting men and planes that the Ukrainians seem ready to accept – have astonished many observers in Kiev after the campaign's faltering start.

The reverses for the separatists, say diplomats, may have made the Kremlin more open to the idea of a negotiated solution – even while Russian politicians publicly deny helping the rebels or being a party to the conflict.

But for Kiev, whose forces now believe they have a chance of stamping out the insurrection altogether, it may be hard to stomach the idea that its interests are best served by stopping the fighting and signing a peace deal.

FACE-TO-FACE

Jan Techau, director of Carnegie Europe, a Brussels-based think tank, believes recent developments on the ground have forced leaders to think more actively about the "long game" in Ukraine, the former Soviet republic that now sits uncomfortably between the European Union and Russia.

That may be the reason why high level contacts between Kiev and Moscow have picked up in recent weeks.

Last Friday, Putin's chief of staff Sergei Ivanov, a former KGB agent and one of the leading Kremlin hawks, met Poroshenko aide Boris Lozhkin in Sochi. And on Sunday, the Ukrainian and Russian foreign ministers met in Berlin at the invitation of their German counterpart, Frank-Walter Steinmeier.

Germany's goal in that meeting was to do the groundwork for a new ceasefire, but in five hours of talks neither Russia's Sergei Lavrov nor Ukraine's Pavlo Klimkin showed much appetite for compromise, according to officials, with Klimkin later taking to Twitter to underline that Kiev would not bend: "In Berlin, Ukraine didn't cross its red lines."

Next week, Putin and Poroshenko are to meet face to face in the Belarus capital Minsk, the first time they have done so since D-Day anniversary celebrations in France in early June.

Poroshenko said on Thursday he would use the meeting to urge Putin to take action to bring about the withdrawal of pro-Russian separatists in eastern Ukraine.

However, both men are under huge pressure from hardliners at home, European officials say, reducing their room for manoeuvre.

"If the Ukraine government consolidates its gains now, Putin loses his proxies in the country," said Techau. "Giving up influence over what is happening in Kiev would be a huge loss for Putin. It would be seen as a defeat."

The difficulty for Merkel is that Poroshenko may believe that a military solution is possible – even though bodies are piling up across the east of the country and Ukrainian warplanes are being regularly shot down.

Even the Germans concede that they are unsure whether Putin, if given the window of a ceasefire to seek a political compromise, will seize the opportunity.

"We know he has to be given a way out. But are we sure he wants a way out? And can we trust him?", said one diplomat who requested anonymity.

Without guarantees from the Russian side, Poroshenko may be reluctant to call off the offensive in the east. Back in June, he called a 10-day unilateral ceasefire only to see Ukrainian servicemen killed by separatist forces.

He says now that renewing the ceasefire is possible only if the rebels lay down their weapons, and is adamant that he wants Russia to cut off military supplies to the separatists.

"(Merkel) knows this is intellectually difficult for Poroshenko and she knows there is a fear of the rebels using a ceasefire to regroup," said the diplomat. "Germany understands this is difficult for him and that is why she is coming to look him in the eye on the issue."

POPULAR MOOD

It is difficult to identify "hawks" in Poroshenko's entourage, though his defence minister, Valery Heletey, when he took office in early July, swore feistily to celebrate victory one day in a Crimea returned to Ukraine.

But the popular mood in Kiev – spawned by the raw "EuroMaidan" revolution of February that chased Moscow-backed president Viktor Yanukovich from power after 100 protesters were shot dead on the streets – seems strongly in favour of defeating the rebels on the battlefield.

A day after Merkel visits, Independence Day celebrations will be held at which 1,500 military personnel - including 150 men from the eastern front - will parade through the capital. Armoured personnel carriers and rocket systems will also be on display.

On Facebook, serving Ukrainian soldiers are urging young people to get trained up and join the ranks. And recruiting campaigns for the National Guard are run regularly on TV.

Poroshenko could dissolve parliament on Sunday, paving the way for parliamentary elections in late October – another reason for not wanting to take a ceasefire decision that might be out of step with popular sentiment.

"They (the Ukrainians) think they must negotiate from a position of strength. And that is the difficulty," the diplomat said.

(Reporting by Noah Barkin in Berlin, Richard Balmforth in Kiev and Christian Lowe in Moscow; Editing by Giles Elgood)