MOSCOW, Russia — Just two months after the inauguration of a friendly president in neighboring Ukraine, Russia has moved swiftly to solidify its influence in the country, making Kiev’s flirtation with the West look like a brief post-Soviet blip.

Today, Ukrainian President Viktor Yanukovych signed into law a deal extending Russia’s lease of a naval base in Crimea, Ukraine’s autonomous Black Sea region. The contentious deal ensures a Russian naval presence on Ukrainian territory through 2042.

In return for the long-sought-after agreement, Russia offered Ukraine a steep discount on gas imports. Ukraine will now pay 30 percent less for its gas, bringing estimated savings of $40 billion over the next decade, and an estimated $3 billion this year alone.

The savings will be key to salvaging Ukraine’s economy, which has been pummeled by the global financial crisis, and to filling budget gaps that have prevented it from appealing to the International Monetary Fund (IMF) for additional aid. (The country took a $16 billion IMF loan in late 2008.)

Yanukovych, long an advocate for close relations with Russia, said during his election campaign that he would seek to balance his country’s relations with Russia and the West.

In some areas, his quick moves to soothe ties with Russia may work in the West’s favor.

A good relationship between Ukraine and Russia means Europe will likely no longer be subjected to the gas cut-offs that became a hallmark of the presidency of Viktor Yushchenko, Yanukovych’s Western-leaning predecessor.

Upon Yushchenko’s election in the 2004-2005 “Orange Revolution,” Russia began raising gas prices to Ukraine, cutting subsidies and moving prices closer to those of its European clients. As payments and deadlines for contract renegotiations neared each New Year’s Day, the war of words grew more heated. Last year, when Russia shut the taps to Ukraine because of failure to pay, some European countries froze for nearly two weeks. (Europe gets most of its Russian gas from pipelines that cross Ukrainian territory.)

“The deal should be a big relief for Europe,” said Fyodor Lukyanov, the editor of Russia in Global Affairs.

Many Russian analysts also believe that Yanukovych’s quick jump eastward means he won’t quickly be seeking a membership action plan with the European Union.

During his election campaign, Yanukovych said EU membership would remain a priority for Ukraine but that he would abandon plans to join NATO, a Yushchenko goal that sorely irked Moscow.

“At this point, I cannot imagine Ukrainian membership in NATO or the EU. Ukraine was and still is a big disappointment for those organizations,” said Vyacheslav Nikonov, a Kremlin-connected political analyst.

A Yanukovych decision against pursuing EU membership might just be an acknowledgment of the difficulties such a bid could face, especially as Brussels deals with the Greek debt crisis and its aftermath. Ukraine is hardly financially healthy, with its economy having shrunk 15 percent last year.

Naftogaz Ukrainy, the state gas company, said the gas deal — which included Russia’s waiving of penalties for late pay — saved it from bankruptcy. It is owed some $500 million in unpaid bills, even though state subsidies means it sells gas to industries and households at prices well below those it paid to Gazprom in the first place.

What the deal does do is strike a blow at Russia’s claim that it has never used its vast energy resources as a coercive weapon.

During each New Year’s dispute, Russia went to great pains to describe the tussle as “purely commercial,” despite critics’ assertions that Moscow was punishing Kiev for turning its back on its one-time patron.

The price Russia charged Ukraine eventually became punitive. By 2010, Ukraine was paying $330 per thousand cubic meters, while countries like the Czech Republic and Hungary were paying about $300, even though their transport costs were higher.

Ukraine will now pay about $230 per thousand cubic meters, something that energy experts see as closer to the market price it should have been paying from the start. Still, it’s being touted by both sides as a significant discount.

“Any price for any commodity includes a commercial, political and geostrategic cost in it,” said Nikonov. “In big deals you cannot distinguish this. Everything is interrelated.”

That’s a different tune than the Kremlin was singing during the disputes that led to gas cut-offs in Europe — New Year’s 2006, 2008 and 2009. Then, it even summoned the promotion skills of top New York and Brussels public relations firms in order to get its message — that the dispute was a market issue — across. Their favorite tactic was pointing out that even at the height of the Cold War, Russia never cut energy supplies to Europe. Nonetheless, the disputes severely damaged Russia’s reputation as a reliable energy supplier.

“This puts politics back at the heart of the Russian-Ukrainian gas relationship,” said a source focusing on energy at an international organization. “While this releases some of the pressure on Ukraine, it doesn’t address some of the key Ukrainian gas vulnerabilities.” Inefficient pricing, reliance on Russia’s lifting of an export duty (which can be reinstated at any time), and industrial waste all continue to wreak havoc on Ukraine’s domestic gas industry and, thus, its economy.

Some Russian analysts say the deal, in exposing Russia’s true motivations, will add, rather than subtract, from its credibility with global partners. “For the first time, Russia is very transparent in terms of its intentions,” said Lukyanov.

Speaking to his cabinet last week, Russian Prime Minister Vladimir Putin said as much. The agreement, he said, was “a qualitative breakthrough in bilateral relations.”

“And money is not the key point here at all,” Putin said. “The key thing is ultimately … the relationship of trust, the understanding of common interests and historical goals and the feeling of fellowship.”