* Dollar posts first yearly gain versus basket since 2005
* Yen a standout in 2008, dollar/yen falls most since 1987
* Pound has worst year versus greenback since 1971 (Adds comments, updates prices, changes byline)
By Wanfeng Zhou
NEW YORK, Dec 31 (Reuters) - The U.S. dollar rose on Wednesday and posted its first yearly gain against a basket of currencies since 2005 as the worst financial crisis in 80 years led investors to take refuge in the greenback.
Despite a deepening recession in the United States, the dollar emerged from a seven-year downtrend as U.S.-based investors brought cash home and overseas investors parked money in the relative safety of dollar-denominated assets such as Treasuries.
The yen was the other top performer this year, soaring as the crisis spurred a massive unwinding of carry trades -- borrowing in the low-yielding yen to invest in higher-yielding assets elsewhere.
Liquidity was thin as traders closed their books on a year in which banks around the globe failed or sought government bailouts following the collapse of a U.S. housing bubble.
Central banks fought aggressively to shore up their economies, with the Federal Reserve and the Bank of Japan cutting rates virtually to zero.
"In forex, the year could be summed up in two words: risk aversion," said Dustin Reid, director for FX strategy at RBS Global Banking & Markets in Chicago. "The yen and the dollar were at the receiving end of that global flight to safety."
In early afternoon trading in New York, the euro <EUR=> was down 0.8 percent to $1.3956 after rising above $1.60 in July.
The euro fell about 4.5 percent against the greenback this year -- its first annual drop since 2005, while the U.S. dollar gained roughly 6 percent versus a basket of currencies <.DXY>.
"The volatility in euro/dollar in 2008 was simply spectacular," said Reid. "At the height of risk aversion a couple of months ago, the entire world rushed to buy dollars. But as the Fed reacted by bringing rates to zero, the dollar's luster has been gradually coming off."
Indeed, in the past few weeks, the euro clawed back a significant portion of its decline from the mid-year peak, gaining nearly 10 percent against the dollar in December, the largest monthly advance since the currency's launch in 1999.
YEN GAINS; POUND TUMBLES
Despite its rally versus higher-yielding currencies such as sterling and the Australian and New Zealand dollars, the U.S. dollar tumbled more than 18 percent against the yen this year, the worst annual performance since a 23.2 percent decline in 1987. The euro was 22 percent lower versus the yen.
The dollar was last up 0.6 percent at 90.84 yen <JPY=> after trading as low as 87.15 to the dollar earlier this month, according to Reuters data.
Sterling stood out as the major loser in 2008, slumping nearly 27 percent against the dollar <GBP=>, the biggest since the last vestiges of the gold standard was abandoned in 1971.
The euro also gained near 30 percent against the pound this year and touched a high of 98.05 pence on Tuesday, within striking distance of parity <EURGBP=D4>.
Investors shunned the pound as the Bank of England lowered interest rates to 2.0 percent, their lowest since the 1950s.
Analysts said that 2008 will remembered as a year of intense volatility as traders used foreign exchanges as a platform to put on risk-averse trades.
"It has been an exceptionally active year in the foreign exchange market as currency volatilities hit record highs," Kathy Lien, director of currency research at GFT Forex in New York, wrote in a research note.
"In the first half of the year, everyone was worried about how much further the dollar would fall but in the second half of the year the concern became how much further the dollar would rise."
While analysts agree that none of the world's major economies will be spared from recession next year, views are divided about how economic weakness will affect currencies.
Jeremy Stretch, a strategist at Rabobank in London, said the euro is likely to continue a slide against the dollar on growing expectations the U.S. economy may be among the first to recover from the downturn.
Other analysts such as Bank of America's David Powell believe that ongoing U.S. economic woes and uncertainty about how the country will fund a massive fiscal stimulus package will hurt the dollar in 2009.
"The trend of dollar weakness is unlikely to have yet seen the end," Powell said. (Additional reporting by Vivianne Rodrigues; Editing by Tom Hals)