BUDAPEST  The Hungarian government struck a deal on Thursday to borrow up to 5 billion euros ($6.7 billion) from the European Central Bank in a bid to avoid becoming  like Iceland  a national victim of the financial crisis.

Hungary is feeling the effects of the credit crisis not because its banks invested in bad mortgages, but because the credit markets have dried up, depriving it of the ability to service debts denominated in currencies other than the Hungarian forint.

The central bank’s loan gives Hungary the means to meet its obligations directly even though harder currencies are flowing out. But the loan comes at a price. The Hungarian central bank had to deposit collateral, denominated in euros, with the European Central Bank.

Addressing the underlying problems will be harder than taking a loan, analysts said. Standard & Poor’s, the ratings agency, put Hungary on review Wednesday for a possible downgrade of its credit rating.