Bulgarian Prime Minister Sergey Stanishev announced that agreement on the controversial project was reached early in the morning.
Until late Thursday both countries had insisted on having a controlling 51% stake in the joint company that is to build and maintain the pipeline and associated equipment.
"This project guarantees Bulgaria’s importance on the energy map of Europe," Stanishev said, adding: "Bulgarian interests are protected."
Russian President Vladimir Putin arrived in Sofia on Thursday together with a delegation that includes chief executives of energy giants Gazprom, Lukoil, and Atomstroieksport and the Mechel mining company.
The South Stream pipeline is to carry Russian gas to Italy and a number of other European countries.
It is an initiative headed by Gazprom and the Italian energy utility, Eni. It will cost some €10 billion.
The joint Bulgarian-Russian company that will build and run the pipeline on Bulgarian territory will be registered in Sofia.
The Bulgarian stretch of the pipeline will cost €1.4 billion. Stanishev said he expected the project to pay for itself within 15 years.
Petar Dimitrov, Minister of Economy and Energy, said that the project would supply Bulgaria with additional gas for its growing economy.
The bilateral agreement will be followed by separate agreements with countries that will be supplied with gas through Bulgarian territory.
Donors spent hundreds of thousands of euro building a new museum in Gjirokastra - but the results were questionable and it ultimately closed over an ideological dispute.