U.S. stocks retreated from record territory Wednesday as technology names came under pressure, but the Dow managed to buck the trend to close higher on the back of a few blue-chip financial shares.

How did the main benchmarks perform?

The Dow Jones Industrial Average DJIA, -0.87% rose 41.31 points, or 0.2%, to a record 26,252.12, with gains in Goldman Sachs Group Inc. GS, +0.01% and American Express AXP, -1.16% offsetting a decline in shares of Apple Inc. AAPL, -3.17% . The blue-chip gauge had been down by triple-digits earlier.

The S&P 500 index SPX, -1.11% shed 1.59 points to 2,837.54, while the Nasdaq Composite Index COMP, -1.07% fell 45.23 points, or 0.6%, to 7,415.06.

All three equity benchmarks had set fresh all-time intraday highs near the start of trade but couldn’t maintain altitude.

On Tuesday, the S&P 500 and Nasdaq again notched all-time closing highs, while the Dow edged back from its then-record close hit on Monday.

The three equity gauges are up between 6% and 8.1% so far in 2018, adding to last year’s sizable gains as investors cheer the expanding U.S. economy and growth in corporate profits. However, the market’s stellar gains have prompted fears of extended valuations.

What drove the markets?

Traders and strategist blamed the afternoon slide to exhaustion, after stocks have notched repeated gains this year. In fact, the three main benchmarks haven’t booked back-to-back losses in January.

Stronger-than-expected corporate earnings have buoyed appetite for equities. Wall Street investors also focused on comments from Treasury Secretary Steven Mnuchin, who said President Donald Trump’s administration supports “bilateral trading agreements,” saying “a weaker dollar is good for trade.” The U.S. dollar DXY, +0.01% , which declined 10% last year, was trading at a fresh three-year low.

Read:Don’t be so surprised by Mnuchin’s endorsement of a weak dollar

A weaker dollar can be a boon for multinational companies offering products and services abroad on price competitiveness.

Mnuchin’s comments also helped push up yields on the 10-year Treasury note higher TMUBMUSD10Y, 0.701% because a weaker dollar can undercut appetite for government paper. Bond prices and yields move inversely. The 10-year yield touched 2.66% earlier, it highest yield since April 2014, but gave up that move to trade at 2.64%. At the same time, rising yields help bolster the businesses of financial firms, lifting interest income.

What were strategists saying?

For historical perspective, John Higgins, chief markets economist at Capital Economics, said Shiller’s cyclically adjusted price/earnings ratio for the S&P 500, a measure of stock valuations, has soared to 34, slightly higher than where it was right before the “Great Crash” in the 1920s. ”Nonetheless, the CAPE remains well below its all-time high of just above 44, which it reached in December 1999, before the dot-com bubble burst,” he said in a note.

“The S&P 500 really is up more than 6% so far this month and shows no sign of abatement,” said Voya Investment Management strategists Doug Coté and Karyn Cavanaugh in a report to clients.

“What could possibly go wrong? Well, one risk to the market could be global trade,” they added, noting that Trump on Monday approved tariffs on imports of solar panels and washing machines.

“Above all else, earnings are doing well and revenue growth is solid to strong,” said Quincy Krosby, chief market strategist at Prudential Financial. “The earnings guidance [from company executives] has been positive and the global economy continues to strengthen. This is all good for the companies,” she said.

Which stocks were key movers?

Shares in Qualcomm Inc. QCOM, -3.64% traded 0.5% lower after the chip company was hit with a $1.2 billion antitrust fine by the European Union. The EU said Qualcomm made illegal payments to Apple for exclusively using its chips in iPhones and other products. Apple shares were off 1.6%.

General Electric GE, -2.41% slid 2.7% after it announced that the Securities and Exchange Commission was probing the process that led to a sizable increase in its insurance reserves last week. The industrial conglomerate also reported weaker-than-expected quarterly results but offered a rosier revenue projection for its power and oil-and-gas business.

Comcast Corp.’s stock CMCSA, -0.70% was up 1.3% after reporting that its earnings were boosted by its broadband business. It also announced plans to repurchase $5 billion in stock in 2018.

Puma Biotechnology Inc.’s shares PBYI, +2.67% slumped 29% after its price target was lowered, notably by J.P. Morgan Chase, as the company said a European Medicines Agency committee completed a negative vote for its breast cancer therapy neratinib.

Shares of United Technologies Corp. US:UTX slipped 0.3% following fourth-quarter results.

Texas Instruments Inc. TXN, -1.23% declined 8.5% after the chip company delivered in-line results and a modest outlook late Tuesday.

United Continental Holdings Inc. UAL, -3.61% fell 11% after the airline posted earnings late Tuesday.

How did other assets fare?

European stocks SXXP, -0.66% ended sharply lower while Asian stocks were a mixed bag.

Gold futures US:GCG8 finished at their highest level in over a year, up more than 1% as the buck skid, while oil futures US:CLH8 climbed more than 2% on the back of supply data.

What economic data were in focus?

The U.S. IHS Markit flash services PMI fell to 53.3 in January, while those for manufacturing rose to 55.5 in January. A reading of 50 or better indicates expanding activity.

Existing-home sales hit a 5.57 million seasonally adjusted annual rate in December, the National Association of Realtors said Wednesday, coming in below the consensus forecast for a 5.73 million rate.

Check out:MarketWatch’s Economic Calendar

—Victor Reklaitis contributed to this article