NEW YORK (Reuters) - The U.S. dollar edged up on Thursday, reversing its recent decline, after U.S. President Donald Trump backed a strong dollar, and the S&P 500 gave back gains on the comments before eking out a record-high close.

Slideshow ( 2 images )

The U.S. dollar .DXY was up 0.17 percent against a basket of major currencies after Trump told CNBC in an interview in Davos, Switzerland, he wants to see a strong dollar.

The comments came a day after U.S. Treasury Secretary Steven Mnuchin, also in Davos, made a major departure from traditional U.S. currency policy, saying “obviously, a weaker dollar is good for us as it relates to trade and opportunities.”

Mnuchin’s comments drove further losses in the dollar on Wednesday, which gave the currency its biggest daily percentage drop in seven months.

“They want to walk back yesterday’s comments. They were salt in the wound,” said Kathy Lien, managing director at BK Asset Management in New York.

But other factors have been driving the extended decline in the dollar, she said. “I think we are due for a rebound. What we are seeing now is some profit-taking.”

The Dow and S&P 500 closed at their highest levels ever although they relinquished bigger gains after Trump’s comments.

The Dow Jones Industrial Average .DJI rose 140.67 points, or 0.54 percent, to end at 26,392.79, the S&P 500 .SPX gained 1.71 points, or 0.06 percent, to 2,839.25 and the Nasdaq Composite .IXIC dropped 3.90 points, or 0.05 percent, to 7,411.16.

The pan-European FTSEurofirst 300 index .FTEU3 lost 0.60 percent and MSCI's gauge of stocks across the globe .MIWD00000PUS gained 0.13 percent.

The euro was EUR= down 0.09 percent to $1.2395. Earlier, the euro rose to its highest in three years after the European Central Bank showed little concern about the euro zone single currency's hottest run in nearly four years.

The ECB kept its ultra-easy monetary policy unchanged. ECB President Mario Draghi cited the region’s “solid and broad” growth and said inflation was likely to rise in the medium term.

U.S. Treasury debt prices rose, boosted by solid demand for 7-year notes as well as Trump’s remarks on the dollar.

U.S. benchmark 10-year notes US10YT=RR last rose 9/32 in price to yield 2.6207 percent, from 2.654 percent late Wednesday.

Oil retreated as the U.S. dollar rebounded from early losses and strengthened, denting support for the latest crude rally.

Brent crude LCOc1, the international oil benchmark, settled down 11 cents at $70.42 a barrel. U.S. crude CLc1 futures for March delivery fell 10 cents to settle at $65.51.