LONDON — After three weeks of urgent negotiations with the interim government of Ukraine and in an atmosphere of great power competition, the International Monetary Fund announced on Thursday an agreement to provide up to $18 billion in loans over two years to prevent the country’s default.

The agreement, announced in Kiev, the Ukrainian capital, will hinge on the country taking steps to let the value of its currency float downward, to cut corruption and red tape, and, crucially, to reduce huge state subsidies for the consumption of natural gas. The energy subsidies alone represent roughly 8 percent of Ukraine’s gross domestic product, and Russia has said that it intends to raise on April 1 the price of natural gas to Ukraine, which is largely dependent on Russian supplies and which already owes the Russian energy company Gazprom well over $1 billion.

The deal, which is subject to the approval of the fund’s board next month, is intended to get the new government over a big hurdle of coming debt obligations when its hard-currency accounts have been sharply diminished by months of unrest that led to the overthrow of former President Viktor F. Yanukovych.

The two-year loan package, the I.M.F. said in a statement, is expected to unlock more loans, including from the United States and the European Union, that should bring the total over two years to $27 billion. The loans will be more spread out and less onerous than the $15 billion Russia had promised Mr. Yanukovych before he fled the country.