A rise in oil prices and strong corporate earnings pushed US markets higher on Friday, but the main financial indices closed down for the week amid turmoil in Washington.
After ceding ground on Wednesday, Friday’s gains were broad-based, powered by firms such as Deere & Co, Chevron and Walmart.
The S&P 500 climbed 0.68%, reaching 2,381.73, while the Dow Jones rose 0.69% to 20,804.84
The Nasdaq hit 6,083.7, up 0.47%.
Stocks have been on a tear in recent months, fuelled in part by hopes that US President Donald Trump would deliver business-friendly tax and regulatory reform.
But on Wednesday, the S&P 500 and the Dow Jones both recorded their biggest one-day falls since September, as pressure mounted on the president.
His firing of former FBI Director James Comey and alleged attempts to influence Comey’s investigation of Trump campaign ties to Russia have caused a furore and led some to talk of impeachment.
The stock swoon left room for recovery on Friday.
US machinery maker Deere & Co’s shares rose 7% after it released results for the three months to April. Net sales in the quarter were $5.8bn, up 1% from the same period a year ago.
But the firm forecast an 9% rise in sales for the financial year, powered in part by a 20% rise in sales of farm machinery in South America.
The outlook spread optimism to Caterpillar, which rose 2.2%.
Other firms disappointed.
Shares in Campbell Soup fell 2% after the food company posted disappointing quarterly results and said its full-year sales could fall.