Industrial companies have led US stocks higher, giving the stock market its second gain in two days.
The rally was broad, with all 11 industry sectors in the Standard & Poor's 500 index closing higher.
That included energy stocks, which climbed as the price of crude oil rose.
The gains helped trim some of the losses that traders booked two days earlier when the stock market posted its worst day in eight months amid deepening political turmoil in Washington.
Investors appeared to shrug off those concerns on Friday, preferring instead to focus on the latest batch of corporate earnings, which included solid results from Deere & Co and other companies.
"If you took a week off, you probably thought you didn't miss much, because we're at about the same levels today as we were last Friday," said Sean Lynch, co-head of global equity strategy at Wells Fargo Investment Institute.
"And yet, we spiked to a new all-time high on the S&P on Monday, we suffered the worst decline of the year on Wednesday, and again we're back within 1% of that all-time high today."
The S&P 500 index rose 16.01 points, or 0.7%, to 2,381.73.
The Dow Jones industrial average added 141.82 points, or 0.7%, to 20,804.84.
The Nasdaq composite index gained 28.57 points, or 0.5%, to 6,083.70. The Russell 2000 index of smaller stocks picked up 6.25 points, or 0.5%, to 1,367.33.
Four stocks rose for every one that fell on the New York Stock Exchange.
Still, indexes ended the week lower.
Bond prices edged lower. The 10-year Treasury yield rose to 2.24% from 2.23% late on Thursday.
Investors had grown concerned on Wednesday that President Donald Trump's pro-business agenda could be hindered by fallout from allegations that he asked the FBI to end an investigation into former national security adviser Michael Flynn, sparking the steep sell-off.
But they remained in a buying mood on Friday, nudging US stock indexes higher early on, extending modest gains from the day before.
"It's clearly been a roller coaster week, with equities being swayed between political uncertainty and improving fundamentals," said Terry Sandven, chief equity strategist at US Bank Wealth Management.
Despite the tumult in Washington, "President Trump's pro-growth agenda of tax reform, less regulation, infrastructure spend and the like, in our view, still remain drivers of higher stock prices".
Traders bid up shares in several companies such as Deere & Co that reported solid quarterly results on Friday.
The heavy equipment maker's shares jumped 8.23 dollars, or 7.3%, to 120.90 dollars.
Autodesk vaulted 14.7% after the design software company raised its earnings forecast for the year and reported a loss in its latest quarter that was narrower than analysts were expecting.
The stock was the biggest gainer in the S&P 500, adding 14.08 dollars to 109.91 dollars.
McKesson jumped 8.2% after the prescription drug distributor reported earnings for its latest quarter that easily beat Wall Street's forecasts. Its shares gained 11.57 dollars to 153.01 dollars.
Ross Stores rose 1.9% after the discount retailer also reported quarterly results that beat Wall Street's estimates. The stock picked up 1.13 dollars to 62.20 dollars.
Some companies turned in disappointing results.
Foot Locker plunged 16.7% after the athletic footwear and apparel retailer's latest quarterly profits fell short of analysts' forecasts.
The stock was the biggest decliner in the S&P 500, shedding 11.73 dollars to 58.72 dollars.
Campbell Soup gave up 2% after the company turned in disappointing quarterly results. Its shares fell 1.16 dollars to 55.78 dollars.
Energy futures closed higher.
Benchmark US crude oil gained 98 cents, or 2%, to close at 50.33 dollars a barrel in New York.
Brent crude, used to price international oils, rose 1.10 dollars, or 2.1%, to settle at 53.61 dollars a barrel in London.
Among metals, the price of gold inched up 80 cents to settle at 1,253.60 dollars per ounce. Silver added 13 cents to 16.80 dollars per ounce. Copper rose five cents to 2.58 dollars per pound.
In currency trading, the dollar weakened to 111.20 yen from 111.49 yen on Thursday. The euro jumped to 1.1205 dollars from 1.1101 dollars.
Several major indexes overseas also posted gains on Friday.
Germany's DAX rose 0.4%, while France's CAC 40 gained 0.7%. Britain's FTSE 100 added 0.5%. In Asia, Japan's benchmark Nikkei 225 gained 0.2%. South Korea's Kospi added nearly 0.1%. Hong Kong's Hang Seng rose 0.3%.