(AP) -- Energy companies led U.S. stocks to modest gains Wednesday as the market recouped some of its hefty losses from the day before.
Big retailers and health care companies also helped lift the market, which was coming off its worst day in almost three weeks. Utilities and phone companies were the biggest laggards. Some travel booking companies and airlines also fell.
"It's a little bit of a rebound from the sort of dramatic day yesterday after everybody got back from the long holiday weekend at the end of the summer and refocused on the market," said Lindsey Bell, investment strategist at CFRA Research. "We've seen that through the past year, any time we've had some sort of dip, it's a buying opportunity for investors."
The Standard & Poor's 500 index rose 7.69 points, or 0.3 percent, to 2,465.54. The Dow Jones industrial average added 54.33 points, or 0.3 percent, to 21,807.64. The Nasdaq composite gained 17.74 points, or 0.3 percent, to 6,393.31. The Russell 2000 index of smaller-company stocks picked up 2 points, or 0.2 percent, to 1,402.20.
The stock indexes are on pace to end the week lower, but are holding on to gains for the year. The S&P 500 and Dow are both up just over 10 percent. The Nasdaq is up 18.8 percent, while the Russell 2000 has gained 3.3 percent.
The market veered higher from the start of regular trading Wednesday and held its course through much of the day. News that President Donald Trump has agreed to a plan to fund the government and increase the nation's debt limit for three months helped lift the market.
"It reassured the market that Washington is on board with stabilizing its financial responsibilities," Bell said.
Tuesday's market jitters over the heated rhetoric between the U.S. and North Korea appeared to ease somewhat on Wednesday, even as investors monitored Hurricane Irma. The mammoth storm, which made its first landfall in the islands of the northeast Caribbean early Wednesday, seemed almost certain to hit the United States by early next week.
A day after spiking more than 20 percent, the VIX, a measure of how much volatility investors expect in stocks, fell nearly 5 percent on Wednesday. And bond yields, which fell sharply a day earlier, rebounded modestly. The yield on the 10-year Treasury note rose to 2.10 percent from 2.06 percent late Tuesday.
Gold, which climbed Tuesday to the highest level in more than a year, fell $5.50 to $1,339 an ounce Wednesday.
Rising oil prices helped boost energy stocks. Helmerich & Payne rose $2.58, or 5.9 percent, to $46.35. Marathon Oil added 44 cents, or 3.9 percent, to $11.73.
All told, benchmark U.S. crude gained 50 cents, or 1 percent, to settle at $49.16 a barrel on the New York Mercantile Exchange. Brent crude, used to price international oils, rose 82 cents, or 1.5 percent, to $54.20 a barrel in London.
Investors also bid up shares in several big retailers.
Gap shares surged 7.4 percent after the apparel retailer said it will shift its focus to its growing brands Old Navy and Athleta, and away from the Gap and Banana Republic. The company said that it will close about 200 Gap and Banana Republic stores in the next three years and open about 270 Old Navy and Athleta stores during the same period. The stock added $1.79 to $25.82. Macy's shares also got a boost, adding $1.16, or 5.5 percent, to $22.17.
Kohl's climbed 4.9 percent after the department store chain said it will open Amazon shops in 10 of its stores. Kohl's shares gained $1.98 to $42.37.
The fallout from Hurricane Harvey, which slammed the Gulf Coast of Texas last month, forced Newell Brands to cut its profit forecast, sending its shares lower Wednesday.
The consumer products maker noted that almost all of its resin suppliers with facilities in Texas and Louisiana shut down after that storm hit. Newell's shares gave up $1.69, or 3.5 percent, to $47.03.
United Continental slid 1.3 percent after the airline cut its third-quarter outlook, citing increased fuel costs due to Harvey. The stock fell 77 cents to $60.33.
Several travel booking companies also slid Wednesday.
Trivago tumbled 16.3 percent after the company cut its profit and revenue guidance. The stock lost $2.44 to $12.49. Rivals Expedia and TripAdvisor also fell. Expedia shed $3.22, or 2.2 percent, to $144.39, while TripAdvisor gave up 24 cents, or 0.5 percent, to $44.31.
The dollar rose to 109.37 yen from 108.66 yen Tuesday. The euro fell to $1.1913 from $1.1918.
In other energy trading, wholesale gasoline dipped 3 cents to $1.67 a gallon. Heating oil rose a penny to $1.76 a gallon. Natural added 3 cents to $3 per 1,000 cubic feet.
Among other metals, silver shed 3 cents to $17.91 an ounce, while copper gained 2 cents to $3.15 a pound.
Global stock markets were mixed. In Europe, Germany's DAX gained 0.7 percent, while France's CAC 40 rose 0.3 percent. The FTSE 100 index of leading British shares fell 0.3 percent.
Earlier in Asia, Japan's Nikkei 225 slipped 0.1 percent and South Korea's Kospi lost 0.3 percent. Hong Kong's Hang Seng index fell 0.5 percent.