Russian President Vladimir Putin started his visit to Budapest on Tuesday with the laying of wreaths at the memorial to Soviet soldiers before heading to a meeting with Hungarian Prime Minister Viktor Orban.
After several hours of talks, the leaders said they had reached an agreement to extend a gas supply contract with Russian energy giant Gazprom that was set to expire at the end of the year.
Hungary is heavily dependent on Moscow for its energy - about 60 percent of its gas supplies come from Russia.
"We value our reputation as a reliable supplier of energy resources in Europe and in Hungary," Putin said at a joint press conference following the leaders' meeting.
Orban said that only "technical" details needed to be ironed out before the deal could be finalized. He explained that a problematic clause in the contract, which obligates Hungary to pay for gas it committed to buy but did not use, had been changed.
The leaders also agreed that Russia's state nuclear power corporation, Rosatom, would start the construction of two nuclear reactor units at Hungary's sole nuclear power plant in the spring, with Moscow providing 10 billion euros ($11.4 billion) to help fund the construction.
Tuesday's trip to Budapest was Putin's first bilateral visit to a European Union country since last June, reflecting a warming in ties between the two countries that has irked some of Hungary's allies in the EU and NATO.
While several European countries have sought to distance themselves from the Kremlin over its alleged role in the conflict in eastern Ukraine, Orban has stressed that Hungary cannot turn its back on its main energy supplier. Orban said he respects the EU sanctions against Russia, but he was quick to highlight their negative impact.
"We are convinced that locking Russia out of Europe is not rational," Orban said. "Whoever thinks…that the European economy can be competitive without economic cooperation with Russia, whoever thinks that energy security can exist in Europe without the energy that comes from Russia, is chasing ghosts."
He added that "Hungary needs Russia" and that it was important for Russia to be open to Hungarian products.
Ahead of Putin's visit, around 2,000 Hungarians held a demonstration in central Budapest to protest against what they see as their government's pivot towards Russia.
Conservative leader Orban - who has led Hungary since 2010 - has, like Putin, faced criticism for his authoritarian style of government and treatment of media and civil organizations.
nm/cmk (AP, dpa)