The Nasdaq composite index rose 27.50 points to 2,058.74, after closing below 2,000 for two days earlier this week. The Dow Jones industrial average gained 68.10 to 10,715.43.
The day's economic data gave conflicting evidence about the state of the U.S. economy.
The country's trade deficit narrowed slightly in April, as exports fell to their lowest level in nearly a year and imports also fell, signaling economic weakness at home and abroad. The trade shortfall totaled $32.2 billion in April, a narrowing of 2.7 percent, or $900 million, from an upwardly revised estimate of $33.1 billion in March, the government said. The March figure was raised by $1.9 billion to reflect seasonal adjustments.
"With both exports and imports down, it's another sign that global activity is slowing down," said Jay Feldman, an economist with Credit Suisse First Boston in New York.
Meanwhile, jobless claims fell unexpectedly, a sign that the economy may not be as bad as economists had thought. Initial claims for state unemployment insurance benefits fell 34,000 to 400,000 in the week ended June 16 from a revised 434,000 the preceding week, defying Wall Street projections for a modest drop to 423,000 from the unrevised measure of 428,000 in the week of June 9.
"This was the lowest level for claims in five weeks," noted Merrill Lynch analyst Bruce Steinberg.
In company news, shares of Transmeta plunged $7.24, or 57 percent, to $5.36 after the company issued a revenue warning and analysts downgraded the stock. The maker of microprocessors for notebook computers and Internet appliances warned on Wednesday that its second-quarter revenue would fall short of estimates.
Exodus, down 65 cents to $1.60, saw heavy selling as analysts questioned the company's ability to survive on dwindling cash reserves and downgraded it. The company issued a second-quarter warning Wednesday night.
Shares for Sanmina, an electronics contract manufacturer, rose $1.10 to $21.18 after falling earlier in the day. It announced on Wednesday evening that third-quarter revenue and earnings will be lower than estimated as a result of a slowdown in its end markets.
Knight Trading Group, a Nasdaq share dealer, said it may cut 6 percent of the employees in its U.S. stocks business as profits are suffering now that shares are traded in pennies rather than fractions. Shares dropped 2 cents to $9.95.
Micron Electronics said it will continue to shed operations and will eliminate its consumer dial-up Internet access business in a bid to improve overall margins. Shares were up 18 cents to $1.48.
Nortel Networks, up 44 cents to $8.45, has been awarded contracts worth about $270 million to expand China Unicom's networks in China.
Among other technology bellwethers, Microsoft rose 43 cents to $69.84, Cisco Systems gained $1.28 to $17.68, Oracle jumped 38 cents to $17.90 and Intel lost 22 cents to $27.27.
Amazon.com was up 55 cents to $13.08, AOL Time Warner gained $2.20 to $55, and Yahoo lost 69 cents to $17.80.
Staff and Reuters contributed to this report.