The Nasdaq composite index rose 9.29 to 2,027.13, and the Dow Jones industrial average gained 121.09 to 10,522.81.
When analysts lowered their estimates for the Standard & Poor's 500 group of stocks Monday, highlighting expectations for bad performance in the technology sector, the Nasdaq proved it could hold steady and closed only marginally down.
U.S. consumer confidence slipped in July as companies continued to lay off workers, according to a report from the Conference Board, a private business research group in New York. The report indicates more sluggish spending and growth ahead but may ensure that the Federal Reserve chops interest rates again next month.
A report on consumer spending and personal income painted a slightly rosier picture. Consumer spending rose by 0.4 percent in June, slightly more that the 0.3 percent economists had expected, and personal income grew by 0.3 percent, a bit better than the 0.2 percent expected.
In one of many moves Tuesday to join forces amid tough times, online brokerage firm Ameritrade said it would buy National Discount Brokers in a stock deal valued at $154 million. Shares were up 53 cents to $6.44.
RSA Security, off 6 cents to $24.49, announced it would purchase privately held Securant Technologies for $136.5 million in cash.
In the Internet consulting field, Scient, off a penny to 54 cents, will merge with Web developer iXL Enterprises, down 47 cents to 53 cents, in an all-stock deal and retain the Scient name.
On the earnings front, Verizon Communications, down $1.87 to $54.15, said its second-quarter profits before charges had gained on strong sales of its data services. But the telephone company cut its growth outlook for the year, blaming the poor economy and slowing demand for basic telephone services.
Server giant Sun Microsystems, up 77 cents to $16.29, has started what it calls a "redeployment," in which hundreds of workers will lose their jobs by the end of the year if they can't find new ones in the company.
Among technology bellwethers, Microsoft rose 39 cents to $66.19, Oracle fell 59 cents to $18.08, Cisco Systems gained 33 cents to $19.22 and Intel rose 77 cents to $29.81.
Amazon.com fell 6 cents to $12.49, AOL Time Warner rose 30 cents to $45.45 and Yahoo fell 18 cents to $17.62.
Server hardware was the best-performing sector. CNET?s server hardware index was up almost 4 percent.
Staff and Reuters contributed to this report.