New York: US stocks finished a banner week on a positive note on Friday amid hopes of a US-China trade detente, as Microsoft overtook Apple in market value.
The Dow Jones Industrial Average finished up 0.8 per cent to 25,538.46.
The broad-based S&P 500 also added 0.8 percent at 2,760.16, along with the tech-rich Nasdaq Composite Index, which finished at 7,330.54.
All three major indices notched strong gains for the week, with the S&P 500's gain of 4.8 per cent the best since December 2011.
On Friday, the leaders of the United States, Mexico and Canada signed a huge regional trade deal to replace the old North American Free Trade Agreement.
Trump also said that were "good signs" ahead of talks with his Chinese counterpart Xi Jinping on the sidelines of a G-20 summit in Buenos Aires.
FTN Financial's Chris Low said the signing of the North American trade agreement was "reassuring" but that many analysts were skeptical of a breakthrough on China.
US stocks have been under pressure for much of the fall due to worries about higher Federal Reserve interest rates and slowing growth from the US-China trade fight.
But stocks gained this week, following a speech from Fed Chair Jerome Powell that investors viewed as dovish.
Big movers in the Dow included Caterpillar, Intel and Coca-Cola, all of which gained about three percent or more. Goldman Sachs was a laggard, dropping 2.2 percent following a downgrade from Bank of America-Merrill Lynch.
Microsoft climbed 0.6 percent to finish with a market capitalization of $851.2 billion, edging out Apple by nearly $4 billion in value. It was the first time in eight years that Microsoft closed above Apple, which slipped 0.5 percent.
Hotel chain Marriott International slumped 5.6 per cent after announcing that it suffered a hack of up to 500 million guests from the Starwood reservation database, which the company acquired in 2016.
General Electric fell 5.5 per cent after a Wall Street Journal report described a deepening US probe into accounting at the slumping conglomerate.
The article quoted one former employee who left the company out of concern that senior executives had not accounted for risk in an insurance division that went on to suffer a $15 billion shortfall.