Gazprom, Russia's state-controlled gas company, had previously been offering Bulgaria a minority stake in the part of the pipeline that would run through Bulgaria.

However, Sofia held out for a deal in which both countries would hold a 50 per cent stake.

Sergei Stanishev, Bulgaria's prime minister, said: "Bulgaria's interests are fully protected, because the company which will be set up to construct and run the pipeline on Bulgarian soil will be with 50 per cent Bulgarian and 50 per cent Russian ownership."

He said Putin deserved most of the credit for progress in the late-night negotiations.

Putin brushed off European concerns about Russia's increasing influence, saying the pipeline agreement and other deals would "seriously increase the energy security of the Balkans, Europe as a whole and, of course, Bulgaria."

He said: "There is a tough struggle among European nations for Russia to build such gas transportation networks.

"The existence of such infrastructure projects raises the economic and political significance of a country, and also brings revenues."

Rival route

South Stream is a direct rival to the projected Nabucco pipeline, sponsored by the US and the EU, which would also run through Bulgaria.

Bulgaria took advantage of the clashing pipeline offers in its hard bargaining with the Kremlin.

The deal has upset opposition parties and non-governmental organisations in the former Soviet satellite, who fear Bulgaria's increasing dependence on Russian energy supplies.

On Thursday, about 100 demonstrators protested against Putin's visit and the deal in central Sofia.

The same day, Georgi Parvanov, Bulgaria's president, underlined his nation's support for the EU's efforts to diversify energy supply routes, and for Nabucco, in a speech at a ceremony marking the opening of a Russian cultural festival in Bulgaria.

A clearly annoyed Putin, standing next to him, said Bulgaria was free to chose its direction but warned it to make sure it "works to its benefit".

South Stream would have an estimated annual capacity of 30bn cubic metres

Officials also signed a $5.9bn contract to build Bulgaria's second nuclear plant, near the northern town of Belene.

There was a further agreement for a joint company, including Greece, to build the Burgas-Alexandroupolis oil pipeline, which will channel Russian oil from the Black Sea to the Aegean, bypassing Turkey's busy Bosphorus.