U.S. stocks advanced for a fourth straight day on Thursday in an end-of-quarter rally that was boosted by a surprisingly strong economic report covering the U.S. Midwest.

Major indexes rose, including the benchmark S&P 500, which climbed above its 50-day moving average at 1,317 despite analysts' expectations it would meet resistance. The index is up 4 percent so far this week.

Regional business activity grew more than expected this month, lifted by a jump in new orders, the Institute for Supply Management-Chicago said. That calmed concerns about the economy that have weighed on markets for two months.

Overseas, Greece's parliament approved measures to implement budget cuts and assets sales, making Greece eligible for financial aid to avoid a debt default.

ISM was really strong, the Band-aid on Greece will shore them up for the short term and rising above the moving average are all helping markets today, said Randy Bateman, chief investment officer of Huntington Asset Management in Columbus, Ohio, which oversees $14.5 billion.

All ten S&P sectors were in positive territory, led by industrials <.GSPI>, up 1.6 percent, and information technology <.GSPT>, up 1.4 percent. Heavy-equipment maker Joy Global Inc rose 4.5 percent to $94.17 while software company NetApp added 5.8 percent to $52.88 for the biggest percentage gain on the S&P 500.

The Dow Jones industrial average <.DJI> was up 125.67 points, or 1.02 percent, at 12,387.09. The Standard & Poor's 500 Index <.SPX> was up 11.02 points, or 0.84 percent, at 1,318.43. The Nasdaq Composite Index <.IXIC> was up 30.80 points, or 1.12 percent, at 2,771.29.

Part of the rally can be attributed to end-of-quarter window dressing by fund managers, who typically sell losers and buy winners to make their portfolios look better.

For the quarter, the S&P 500 is down 0.5 percent while the Dow rose 0.6 percent and the Nasdaq is off 0.3 percent.

Shares of Ford Motor Co shot up 3.3 percent to $13.86 after an analyst projected the U.S. automaker gained market share in June.

EBay Inc rose 4.1 percent to $32.10 after both Citigroup and Bank of America-Merrill Lynch upgraded the stock, citing a Federal Reserve ruling that third-party networks like eBay's PayPal will not be regulated like payment networks.

First Solar Inc surged 4.2 percent to $134.91 after the solar panel maker won conditional loan guarantees from the U.S. Department of Energy worth $4.5 billion for three of its largest projects.

The Federal Reserve ended its $600 billion bond-buying program, known as QE2, on Thursday and has not offered any hints of more monetary easing. Markets were volatile in May and June, partly on concerns about QE2's end.

(Editing by Kenneth Barry)