(Reuters) - Japan logged its first annual trade deficit in 2011 for over 30 years as the aftermath of the March earthquake raised fuel import costs even as slowing global growth and the yen's strength hit exports, threatening to erode the country's ability to fund its huge public debt with domestic savings.

Few market players expect Japan to immediately run a deficit in the current account, which includes trade and returns on the country's huge past investments abroad, as a steady inflow of profits and capital gains from overseas outweigh the trade deficit.

But the trade data underscores a broader trend in which Japan's competitive edge in the global market is eroding and it is increasingly reliant on fuel imports due to the loss of nuclear power, with reactors staying closed after routine checks due to public safety fears following the March disaster.

What it means is that the time when Japan runs out of savings -- 'Sayonara net creditor country' -- that point is coming closer, said Jesper Koll, head of equities research at JPMorgan in Japan.

It means Japan becomes dependent on global savings to fund its deficit and either the currency weakens or interest rates rise.

Japan logged a trade deficit of 2.49 trillion yen ($32 billion) for 2011, Ministry of Finance data showed on Wednesday, the first annual deficit since 1980.

Total exports shrank 2.7 percent last year while imports surged 12.0 percent, reflecting reduced earnings from goods and services and higher spending on crude and fuel oil.

In a sign of the continuing pain from slowing global growth, exports fell 8.0 percent in December from a year earlier, roughly matching a median market forecast for a 7.9 percent drop, due partly to weak shipments of electronics parts.

Imports rose 8.1 percent in December from a year earlier, in line with a 8.0 percent annual gain expected, bringing the trade balance to a deficit of 205.1 billion yen, against 139.7 billion yen expected. It marked the third straight month of deficits.

Bank of Japan Governor Masaaki Shirakawa said on Tuesday he did not expect Japan to continue logging a trade deficit as a trend and did not foresee the country's current account balance tipping into the red in the near future.

But Japan's days of logging huge trade surpluses may be over as it relies more on fuel imports, which may weaken the yen in the longer term.

Running a current account deficit would spell trouble for Japan as it means it cannot pay the cost of financing its huge public debt without overseas funds, although few analysts expect this to happen in the foreseeable future