Japan first annual trade deficit in more than 30 years calls into question how much longer the country can rely on exports to help finance a huge public debt without having to turn to fickle foreign investors.

The aftermath of the March earthquake raised fuel import costs while slowing global growth and the yen's strength hit exports, data released on Wednesday showed, swinging the 2011 trade balance into deficit.

Few analysts expect Japan to immediately run a deficit in the current account, which includes trade and returns on the country's huge portfolio of investments abroad. A steady inflow of profits and capital gains from overseas still outweighs the trade deficit.

But the trade figures underscore a broader trend of Japan's declining global competitive edge and a rapidly ageing population, compounding the immediate problem of increased reliance on fuel imports due to the loss of nuclear power.

Only four of the country's 54 nuclear power reactors are running 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.

That prospect could give added impetus to Prime Minister Yoshihiko Noda's push to double Japan's 5 percent sales tax in two stages by October 2015 to fund the bulging social security costs of a fast-ageing society.

The biggest opposition party, although agreeing with the need for a higher levy, is threatening to block legislation in parliament's upper house in hopes of forcing a general election.

Japan logged a trade deficit of 2.49 trillion yen ($32 billion) for 2011, Ministry of Finance data showed, the first annual deficit since 1980, after the economy was hit by the shock of rising oil prices.

Were Japan to run a current account deficit, it would spell trouble because it would mean the country cannot finance its huge public debt -- already twice the size of its $5 trillion economy -- without overseas funds.

Japanese investors currently hold about 95 percent of Japan's government bonds, which lends some stability to an otherwise unsustainable debt burden.

Domestic buyers are less likely to dump debt at the first whiff of economic trouble, unlike foreign investors, as Europe's debt crisis has shown.

The trade data helped send the yen to a one-month low against the dollar and the euro on Wednesday.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Graphic on 2011 trade data http://link.reuters.com/mev26s

Dec trade balance http://link.reuters.com/vyq65s

Exports by destination http://link.reuters.com/far65s

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

HOLLOWING OUT, AGEING POPULATION

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. Annual imports of liquefied natural gas hit a record high.

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.

Japan managed to sustain annual trade surpluses through the Asian financial crisis of the late 1990s and the post-Lehman Brothers global recession that started in late 2008, which makes the 2011 dip into deficit all the more dramatic.

A generation ago, Japan was the world's export juggernaut, churning out a stream of innovative products from the likes of Sony and Toyota.

Much like China today, Japan's bulging trade surplus became a source of friction with the United States and other advanced economies, who pressed Tokyo to allow the yen to rise more rapidly in order to reduce the imbalance.

A 1985 agreement between Japan, the United States and Europe's big economies -- known as the Plaza Accord after the New York hotel where it was signed -- pushed the yen higher against the U.S. dollar.

Many economists argue that sowed the seeds of Japan's current debt woes. After the Plaza Accord, Japan's economy weakened and its central bank slashed interest rates, which contributed to a credit boom that eventually spawned a financial crisis and led to two decades of economic stagnation.

Bank of Japan Governor Masaaki Shirakawa said on Tuesday he did not expect trade deficits to become a pattern, 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 and manufacturers move production offshore to cope with rising costs and a strong yen, a trend that may weaken the Japanese currency longer term.

A fast-ageing population also means a growing number of elderly Japanese will be running down their savings.

Chief Cabinet Secretary Osamu Fujimura said the government wants to closely watch the trend of exports and imports.

There are worries that the yen's strength is driving Japanese industry to go abroad, said Fujimura. We have to create new industries ... implement comprehensive steps to boost growth. It is important to secure employment within the nation.

($1=77.71 yen)

(Additional writing by Leika Kihara; Editing by Linda Sieg and Emily Kaiser)