"Nord Steam 2 is purely an economic project and it doesn't close the door to shipping gas through Ukraine", Putin said.
"That's why it is necessary to take measures against possible non-competitive and illegal attacks from the third countries in order to complete this project eventually", he told reporters shortly before Putin flew back to Russian Federation.
On the planned Nord Stream 2 pipeline to carry Russian gas under the Baltic to Germany, Merkel said Ukraine should continue to have a role in gas transit to Europe, and welcomed the start of discussions among the European Union, Ukraine and Russia on that issue.
Russian Federation and the West remain locked in dispute over Moscow's annexation of Ukraine's Crimean Peninsula in 2014 and the conflict between Kyiv and Russia-backed separatists in eastern Ukraine.
"I would like to stress that the main thing is that the Ukrainian transit - which is traditional for us - meets economic demands", he said. Work on a new gas pipeline linking the two countries, the Gazprom PJSC-backed Nord Stream 2, began in May amid a USA threat of sanctions targeting the project.
The two leaders discussed Syria, Ukraine and the Nord Stream 2 pipeline.
"In 2017, we delivered 53.8 bln cubic meters of gas, which covers more than 30% of the German market, while the consumption of Russian gas is constantly growing and this year it increased by 13%", he said.
Peskov said the threat of possible USA sanctions against companies involved in the project was not discussed on Saturday.
"Merkel is hedging and Putin is exploiting", Josef Janning, senior policy fellow at the European Council on Foreign Relations in Berlin, told Bloomberg.
Other topics on the pair's agenda are Iran, human rights and "other bilateral issues", Ms Merkel said.
Russian President Vladimir Putin (right) and German Chancellor Angela Merkel at a news conference in the Russian Black Sea resort of Sochi, Russia.
Both leaders raised concerns about Syria and the plight of the many refugees created by the seven-year-old war there.
"This is potentially a huge burden on Europe, so it is better to do everything possible so that they can return home".
Putin told reporters that such a move had to make sense for Moscow from a business perspective. The two leaders took no questions.
Austrian authorities imposed tight security measures around the site of the ceremony near the southern border with Slovenia, where Foreign Minister Karin Kneissl married her partner Wolfgang Meilinger, a businessman.
Earlier, Germany's foreign minister Heiko Maas said he was "relatively optimistic about the chances of a United Nations mission", telling the Die Welt newspaper: "We want to give a new dynamic to the Minsk process".