NEW YORK — U.S. stocks rallied for a second day on Wednesday, as earnings topped forecasts and the Federal Reserve said the labor and housing markets are improving.

NEW YORK — U.S. stocks rallied for a second day on Wednesday, as earnings topped forecasts and the Federal Reserve said the labor and housing markets are improving.

Gilead Sciences climbed 2.3 percent while General Dynamics and Northrop Grumman jumped more than 3.9 percent as the companies lifted their outlooks. Twitter tumbled 15 percent after its top executives struck a critical tone on user growth.

The Standard & Poor’s 500 Index rose 0.7 percent to 2,108.57 at 4 p.m. in New York, after climbing above its average prices during both the past 50 and 100 days. The Dow Jones industrial average added 121.12 points, or 0.7 percent, to 17,751.39. The Nasdaq Composite Index gained 0.4 percent.

"Most peoples’ expectations are that we’re going to get a hike by the end of the year, and the Fed (statement) today didn’t do anything to change that narrative," said Joe Bell, a Cincinnati-based senior equity analyst at Schaeffer’s Investment Research

The labor market "continued to improve, with solid job gains and declining unemployment," the Federal Open Market Committee said in a statement on Wednesday, while also noting the housing sector "has shown additional improvement."

Chair Janet Yellen is guiding the Fed toward its first rate increase in almost a decade as the nation approaches full employment. She has said the Fed is likely to tighten this year if the economy continues to improve as she expects, with market speculation focused on a move as soon as September.

Yellen has emphasized that the timing of rate liftoff is less important than the subsequent pace of increases, which she said would be gradual.

Greece’s debt crisis and recent turmoil in China’s stock market had raised concerns about global growth and added to speculation that the Fed may further delay a rate increase.

Earlier this month, Yellen told lawmakers that raising rates prematurely could derail the recovery. Waiting too long, on the other hand, might force the Fed to tighten at a faster pace to keep the economy from overheating.

"The Street clearly has a tug-of-war going on between the camp that sees enough evidence and wants to get a hike under the belt, and another camp that would prefer the Fed to be cautious and wait until later in the year," said Myles Clouston, senior director of Nasdaq Advisory Services in New York.

Goldman Sachs Group Chief Executive Officer Lloyd Blankfein said U.S. markets are poised for prolonged growth and will quickly move on after a jolt from the Fed’s first rate increase since 2006.

"We are in for a longish, positive market," Blankfein said today in an interview on Bloomberg Television. "Since the financial crisis, especially in this country, there were a lot of problems, but we chewed through them. Consumers have deleveraged, the banking system has deleveraged, we got the blessing of low energy prices, housing prices started to stabilize and move higher."

Data today showed an index of pending home sales unexpectedly fell 1.8 percent, the first drop this year, after a revised 0.6 percent increase in May that was smaller than initially reported.

The S&P 500 is up 2.2 percent in July, heading for its biggest monthly advance since February. The index rose yesterday after declining for four of the last five weeks, and had lost 2.9 percent in the five sessions ending on Monday as a Chinese equities rout spurred concern about the nation’s economic growth and some corporate earnings disappointed.

About three-quarters of S&P 500 companies that have reported earnings this season have beaten profit estimates while half topped sales projections. Analysts expect a 4 percent drop in second-quarter earnings, shallower than July 10 calls for a 6.4 percent fall.

Facebook slipped 1.8 percent in late trading as of 4:45 p.m., after spending in the second quarter jumped 82 percent. Sales topped estimates, thanks to a robust advertising business and a growing number of mobile users.

The Chicago Board Options Exchange Volatility Index slipped 7 percent Wednesday to 12.50, after reaching a two-week high Monday. The gauge, know as the VIX, rose 15 percent last week, its fifth gain in six weeks. About 7.3 billion shares traded hands on U.S. exchanges, 12 percent above the three-month average.

All of the S&P 500’s 10 main groups advanced, led by energy and industrial companies. C.H. Robinson Worldwide paced industrial shares’ advance, climbing 4.7 percent after reporting second-quarter profit that exceeded analysts’ estimates.

The freight carrier also helped lift the Dow Jones Transportation Average to its strongest two-day climb since November 2011. General Dynamics and Northrop Grumman also bolstered industrials, gaining more than 3.9 percent to records. Raytheon added 4.1 percent to a three-month high.

Energy and raw-material shares added to Tuesday’s rally amid a continued reprieve from a two-week commodities selloff. Crude oil extended its two-day climb to 3.1 percent, pushing Anadarko Petroleum and Diamond Offshore drilling up more than 3.5 percent. Pioneer Natural Resources and Transocean added at least 2.4 percent.

Banks in the benchmark rallied as Treasury yields increased to the highest in a week. Bank of America , JPMorgan Chase and Comerica each added at least 1.3 percent.

Citrix Systems climbed 8.1 percent, the most since January 2013, to lead S&P 500 technology companies higher. The software maker reached a settlement with investor Elliott Management , agreeing to add the activist’s chief agitator Jesse Cohn to its board and begin a search for a new chief executive officer.

Microsoft gained 2.1 percent, the most in seven weeks, amid a low-key introduction for its Windows 10 operating system. MasterCard erased an earlier drop of as much as 2.3 percent to climb 1.7 percent, even as the second-largest payments network said profit fell 1.1 percent as expenses rose and a strengthening U.S. dollar hurt earnings overseas.

Twitter slipped 15 percent, the most since April. Interim Chief Executive Officer Jack Dorsey and Chief Financial Officer Anthony Noto said user growth won’t improve until the social- media company reaches a mass market — something that will take a mixture of product improvements and marketing.

Yelp plunged by a record 25 percent after the customer-review website reduced its revenue forecast and at least five analysts downgraded the stock. In addition to cutting its third-quarter sales prediction, Yelp announced it would stop selling national brand advertising.

—With assistance from Roxana Zega in Zurich and Callie Bost in New York.