U.S. stocks soared late Friday just before the close of the May month giving Wall Street a gain for a third consecutive month.

Wall Street reported a 5.3% gain for the month of May.

After fluctuating much of the day on mixed economic data, stocks rallied just before the close.

The Dow Jones Industrial Average rose 109.28 points, or 1.3%, at 8513.08, while the S&P 500 was 12.86 points, or 1.4% higher, at 919.69. The Nasdaq was better by 22.54, or 1.3%, at 1774.33.

For the week, the Dow was up 2.8%, the S&P 500 higher by 3.7%, and the Nasdaq up 4.9%. The expression sell in May and go away did not hold: The Dow was up 4.2%, the S&P 500 was higher by 5.4%, and the Nasdaq added 3.3% for the month.

Analysts also said a jump in commodities prices, which came on expectations that an improving economy will lift demand for raw materials, fed the late-day advance. The commodities rally likely convinced short sellers that they needed to buy.

GM has reportedly also reached a tentative deal with Canadian auto-parts maker Magna to sell its German unit, Opel, ahead of its expected bankruptcy filing next week.