* Markit manufacturing data way ahead of expectations
* Tesla shares soar after results, Wal-Mart falls
* Facebook to buy WhatsApp for $19 bln, shares flat
* Indexes up: Dow 0.68 pct, S&P 0.57 pct, Nasdaq 0.46 pct
NEW YORK, Feb 20 (Reuters) - U.S. stocks rose on Thursday after a reading on manufacturing activity hit a four-year high, more than offsetting other soft data and weak results from Wal-Mart.
Major indexes swung between slight gains and losses in early trading but were clearly in the black after noon. At its session high, the S&P 500 was less than 0.5 percent from its record close set last month at 1,848.38.
U.S. factory activity accelerated at its fastest pace in nearly four years in February, according to Markit's preliminary U.S. Manufacturing Purchasing Managers Index, a bullish economic indicator following a string of weaker-than-expected reports.
New filings for unemployment insurance fell in the latest week, boding well for the job market, but the Philadelphia Fed's gauge of manufacturing activity unexpectedly contracted in February.
The equity market has selectively shrugged off tepid data, pinning recent weakness to the impact of extremely cold weather and massive snow rather than worsening fundamentals.
"The U.S. (Markit) PMI number was probably not as good as it seems, there could be some noise there, but it certainly is a good number," said Paul Zemsky, head of asset allocation at ING Investment Management in New York.
"Overall, I think the data is a little equity positive. I don't think this is sufficient to take us past 1,850 (on the S&P 500). We need a reasonably good (payrolls) number for that. I think we still coil here for a few sessions, but we'll break to new highs because the economy is going to show the slowdown was weather-related."
The Dow Jones industrial average rose 108.47 points or 0.68 percent, to 16,149.03, the S&P 500 gained 10.47 points or 0.57 percent, to 1,839.22 and the Nasdaq Composite added 19.705 points or 0.46 percent, to 4,257.659.
Wal-Mart Stores Inc fell 1.8 percent to $73.49 after the world's biggest retailer reported a drop in U.S. same-store sales and gave an earnings outlook below expectations.
Social networking giant Facebook said late Wednesday it would buy mobile-messaging startup WhatsApp for $16 billion in cash and stock, plus $3 billion worth of restricted stock units to WhatsApp's founders. Facebook shares edged up 0.3 percent to $68.25 in heavy volume.
Tesla surged 9.2 percent to $211.47 a day after it reported fourth-quarter results that topped expectations and said deliveries of its luxury Model S electric sedan would surge more than 55 percent this year.
Emerging market growth was also in view after China's flash Markit/HSBC Purchasing Managers' Index fell to a seven-month low in February.
"The market's strength is somewhat surprising given how weak overseas markets have been," said Nicholas Colas, chief market strategist at the ConvergEx Group in New York.
"It is good to see investors buying on dips, but I've also been hearing a lot more bearish chatter."
Quanta Services jumped 6.4 percent to $34.14 after reporting its fourth quarter results.