By Jamie McGeever

LONDON (Reuters) - Investors rekindled their love affair with emerging markets this year, pouring billions of dollars into their stocks and bonds, but the prospect of the Federal Reserve raising U.S. interest rates threatens to cool the relationship once again.

Higher U.S. rates and bond yields tend to make emerging market assets relatively less attractive and push up the dollar, inflating the amount of dollar-denominated debt held by emerging market borrowers.

Recent history suggests the smallest increase - or even a whiff of an increase - can be unnerving for emerging markets, where borrowers hold more than $3 trillion of U.S. currency-based debt and where investors have built up their exposure recently.

In May 2013, Ben Bernanke, then the Fed chairman, prompted the so-called "taper tantrum" when he indicated that rates were about to rise. The subsequent volatility across emerging markets saw bond yields rise, spreads widen and the MSCI emerging market equity index slump 15 percent over the next month.

And when it became clear that the Fed would deliver its first rate hike in a decade last December, emerging markets again wobbled. The MSCI index fell 20 percent from November to January.

Futures markets are now tilting towards the Fed moving again by December, albeit tentatively. Several Fed officials have said in recent weeks that this is on the cards, although investors have yet to be fully persuaded.

San Francisco Fed President John Williams said on Tuesday that he favored raising rates "sooner rather than later". His comments were particularly hawkish, considering figures earlier in the day showed the biggest slowdown in U.S. service sector growth since 2008.

"The collapse in U.S. real rates is probably the single most important event of this year for emerging markets," said Bhanu Baweja, a strategist at UBS, citing one of the main reasons emerging market assets have performed so well.

"If it's a dovish hike, EM could be seen as a buying opportunity. But if the Fed indicates a fairly conventional 'normalization' path for rates and inflation expectations pick up, there's no doubt EM will take a hit," he added.

BIPOLAR

Several measures of emerging market flows and investment trends this year tell the same story: a large influx of cash has turbo-charged equity, fixed income, credit and commodity markets, reducing bond yields and spreads.

This has been partly down to the steep selloff in EM assets in the preceding 18 months, which coincided with the dollar's 27 percent surge in 2014 and 2015. That was the greenback's biggest two-year rally since the mid-1980s.

It's also partly because EM assets offer much higher returns than developed markets, where yields have never been lower and are even negative across Japan and much of Europe.

Emerging market portfolio inflows this year are approaching $80 billion, according to the Institute of International Finance, around three quarters of which has gone into equities and a quarter into bonds.

Much of that was in the last three months, making it a sizzling summer for emerging markets. Developed equity, bond and currency markets lacked clearer direction.

MSCI EM stocks since 2009: http://tmsnrt.rs/2c9OizD

EM FX vs dollar this year: http://link.reuters.com/map94w

EM stocks this year: http://link.reuters.com/weh36s

EM assets this year: http://reut.rs/1ZKAaO6

EM stocks vs global stocks: http://bit.ly/2bStoSB

Figures from Bank of America Merrill Lynch show record-breaking inflows into emerging market equity mutual funds of almost $24 billion over the last 10 weeks.

Similarly, emerging market debt funds have attracted the biggest ever inflows over the past 10 weeks, according to BAML. Those flows may be poised to reverse.

"EM is a bipolar asset class – you either love it or you hate it, and you can love it and hate it in the same year," said Timothy Ash, managing director and senior CEEMEA desk strategist at Nomura.

HSBC's asset allocation team last week slashed emerging market debt's share of its global portfolio by 17 percent percentage points to just 4 percent, and the EM equity holdings, too.

Not everyone agrees that emerging markets are so vulnerable. Alexis De Mones, head of fixed income at Ashmore, believes they are far more resilient to rising U.S. rates now than they were at the time of the 'taper tantrum'.

As De Mones points out, the average EM current account deficit then was 2.1 percent of economic output, meaning the countries were on average net debtors. Today, EM national accounts are broadly in balance, making these countries "much more resilient" to higher dollar borrowing costs.

(Reporting by Jamie McGeever, Karin Strohecker and Mike Dolan; Graphics by Jamie McGeever and Marc Jones; Editing by Larry King)