U.S. stocks got a lift on Friday from Caterpillar and other U.S. industrials' shares, putting the Dow in line for its best monthly performance since December.

Heavy machinery manufacturer Caterpillar Inc climbed after reporting a fivefold increase in quarterly profit and raising its full-year forecast.

This whole rally we've seen has been earnings driven, said Tim Ghriskey, chief investment officer of Solaris Asset Management in Bedford Hills, New York.

The corporate earnings and corporate revenues are much stronger than the economic data would indicate and that is why we keep marching higher here.

The blue-chip Dow average was up 4.1 percent for the month while the S&P 500 has risen 2.8 percent and the Nasdaq has gained 3.3 percent. The Nasdaq was also heading for its best month of the year, while the S&P 500 was aiming for its best month since February.

April's gains, however, were limited by slides in Microsoft Corp , the Nasdaq index's most heavily traded stock, and BlackBerry maker Research in Motion .

Caterpillar gave the top boost to the Dow, advancing 2.8 percent to $115.83, after reaching an all-time high of $116.25 during the session. The S&P industrial sector index <.GSPI> gained 0.4 percent. Caterpillar is up more than 20 percent so far this year, along with fellow industrial Boeing Co .

Microsoft dropped 4.5 percent to $25.51 and was the biggest drag on the blue-chip Dow after it reported a drop in quarterly sales of its Windows software, mirroring a recent downturn in demand for personal computers. U.S.-listed shares of Research in Motion tumbled 13.8 percent to $48.77 after the BlackBerry maker cut its first-quarter forecasts.

The Dow Jones industrial average <.DJI> gained 50.56 points, or 0.40 percent, to 12,813.87. The Standard & Poor's 500 Index <.SPX> added 2.76 points, or 0.20 percent, to 1,363.24. The Nasdaq Composite Index <.IXIC> was up just 0.21 of a point, or 0.01 percent, at 2,872.74.

Merck & Co Inc reported higher-than-expected quarterly earnings, fueled by strong sales of drugs for diabetes, asthma and rheumatoid arthritis, while Chevron Corp reported a jump in earnings as oil prices surged.

Shares of Merck rose 0.4 percent to $35.92 while Chevron added 0.4 percent to $109.29. Both stocks are Dow components.

Robust corporate earnings, ample liquidity from the Federal Reserve and the prospect of ultra-low interest rates for the rest of the year have sparked bullishness, pushing the Nasdaq to a 10-year high and lifting the S&P 500 more than 8 percent this year. The major U.S. stock indexes also hit new yearly highs during the week.

With May, the market is heading into a typically weak period. May has been the fourth-weakest month for the Dow, averaging a 0.2 percent gain since 1950, according to the Stock Trader's Almanac. It also normally marks the start of the worst six months of the year for the industrials.

The dollar held near a three-year low against a basket of currencies.

(Reporting by Chuck Mikolajczak; Editing by Jan Paschal)