By Anora Mahmudova and Carla Mozee, MarketWatch

NEW YORK (MarketWatch) -- Stocks ended mixed Friday, trimming or erasing losses after falling on news of a clash between Ukrainian and Russian military units on Ukraine soil. Major indexes posted weekly gains despite the late flight out of riskier assets into Treasurys.

The S&P 500 (SPX) fell 0.12 point, or less than 0.1%, to end at 1,955.06 after trading as low as 1,941.40, leaving the index with a 1.2% weekly gain. The Dow Jones Industrial Average (DJI) trimmed a triple-digit loss to end the day down 50.67 points, or 0.3%, at 16,662.91, making for a weekly rise of 0.7%. The Nasdaq Composite (RIXF) returned to positive territory, rising 11.93 points, or 0.3%, to 4,464.93 and notching a 2.2% weekly advance.

Ukrainian forces destroyed part of a Russian military unit that was on Ukrainian soil, a Ukrainian military spokesperson said Friday, according to news reports. Separately, NATO's secretary-general said the alliance observed a Russian "incursion" into Ukraine, denied by Russia, on Thursday night, according to the Associated Press.

"Markets are reacting this afternoon to the ongoing developments, but in the fog of war it makes little difference what the specific elements are in each event. Instead, what drives market valuations is the knowledge of applied costs. No matter how Ukraine, Russia, and the separatists sort themselves out, the costs continue to rise," said David Kotok, chief investment officer at Cumberland Advisors, in a note.

The 10-year Treasury note yield (10_YEAR) fell more than 5 basis points to less than 2.35% as investors sought safety by buying Treasurys. Yields fall as Treasury prices decline.

Haven-related buying only provided a modicum of help for gold, however, which trimmed losses but still settled at its lowest level since Aug. 5. Friday's losses on the main benchmarks put a cap on weekly gains. Stocks trimmed initial losses ahead of the closing bell.

John De Clue, chief investment officer at the Private Client Reserve of U.S. Bank, said he isn't surprised that stocks have been so resilient in the face of geopolitical concerns.

"Second-quarter earnings have been better than many of us expected and the economy is growing. The fact that we are not seeing larger pullbacks mean that investors are not alarmed by the impact of geopolitical issues," he said.

Still, the entanglement overshadowed more signs that the U.S. economy remains healthy and that company profits are increasing. Industrial production rose in July, thanks to a sizable jump in car output, the Federal Reserve said Friday.

Meanwhile, U.S. producer prices inched up in July, a second consecutive month of gains, led by services such as transportation and warehousing, the government reported Friday. That is one of several recent inflation gauges that show price growth isn't running too hot for the Fed.

Investors shrugged off a preliminary August reading on the University of Michigan/Thomson Reuters consumer-sentiment index that showed it at the lowest level since November.

Stocks in focus

Monster Beverage (MNST) shares surged to lead the S&P on Coca-Cola's (KO) move to acquire a 17% ownership stake in the energy drink company, as part of a long-term partnership deal. Coke will make a $2.15 billion cash payment and transfer its global energy drink business to Monster.

Applied Materials Inc. (AMAT) was among the biggest advancers in the S&P, after the chip-making equipment provider's quarterly sales and earnings report topped Wall Street expectations.

Achillion Pharmaceuticals (US-ACHN) rallied in heavy volume following positive results from a clinical trial related to sovaprevir, the company's experimental hepatitis C treatment.

Autodesk Inc.(ADSK) shares led S&P losses after the design-software company late Thursday forecast a tepid outlook. Read more about the day's notable movers here.

In Asia, Hong Kong's Hang Seng Index finished at its highest level in more than three years. European stocks ended lower after headlines of conflict escalation in Ukraine.

More must-reads from MarketWatch:

SeaWorld bows to "BlackFish" pressure

Does George Soros know something we don't?

How to choose between a pension and a 401(k)

Subscribe to WSJ: http://online.wsj.com?mod=djnwires

Coca Cola (NYSE:KO)
Historical Stock Chart
From Feb 2024 to Mar 2024 Click Here for more Coca Cola Charts.
Coca Cola (NYSE:KO)
Historical Stock Chart
From Mar 2023 to Mar 2024 Click Here for more Coca Cola Charts.