Stocks rebounded from choppy trading Wednesday to post gains after the government reported the largest monthly budget surplus in three years and oil prices dropped on U.S. supplies data.

The Dow Jones industrial average (search) gained 19.14 points, or 0.19 percent, to end at 10,300.25. The technology-laced Nasdaq Composite Index (search) ended higher 8.78 points, or 0.45 percent, at 1,971.55 while the broader Standard & Poor's 500 (search) index was up 4.89, or 0.42 percent, to settle at 1,171.11.

Trading was choppy and stocks were mired in negative territory for most of the session.

However, all three major indexes recovered losses toward the end of the day as investors regained confidence when the Treasury Department released data showing the budge surplus swelled to $57.71 billion in April, the largest amount in more than three years.

Also contributing to the late comeback were lower oil prices. U.S. crude prices settled down $1.62 at $50.45 a barrel — the first daily loss in six trading days — while London's Brent crude dropped $1.36 to $50.07. Behind the drop in prices was a U.S. government reported that showed a larger-than-expected stockpile of oil and gasoline. Falling oil prices have eased concerns about crimped corporate profits and slack consumer spending.

Stocks plummeted at noon after it was reported the White House and the Capitol were evacuated after a small plane evacuated the restricted airspace over Washington. All three indexes recovered some losses after the evacuation order was lifted.

The session started in positive territory after the Commerce Department released a report before the opening bell saying the U.S. trade deficit unexpectedly narrowed to $55 billion in March, the lowest level in six months. The report said exports climbed to an all-time high and the deficit with China declined, reflecting a slowdown in the surge of textile shipments from that country.

The gap narrowed 9.2 percent and was down from the record monthly deficit of $60.57 billion set in February.

"We have a market that is trading aimlessly, looking for a reason to go in either direction and today the information was mixed." Anthony Chan, senior economist, JPMorgan Asset Management, said on the economic data. "The trade deficit was a good number, but it's not clear that this is a real fundamental change. And I think on the margin, lower oil prices helped today."

In corporate news, United Parcel Service Inc. (UPS) rose 3 percent to $73.85, after it said U.S. volume growth was well ahead of expectations for the second quarter as it moved more goods for mid-sized companies.

Eastman Kodak Co. (EK), in the midst of a difficult transition from film-based photography to digital, rose $1.13 to $26.58 after it said Chief Executive Daniel Carp would step down in favor of his second-in-command, Antonio Perez.

The Walt Disney Co. (DIS) sagged 28 cents at $26.67, even after the company reported strong gains in quarterly revenues and earnings. The company's quarterly report was released early, during the session, due to an e-mail containing earnings information was inadvertently sent.

Cisco Systems Inc. (CSCO) rose 2 percent, or 34 cents, to $18.55, helping the tech-heavy Nasdaq, a day after it posted a 16 percent rise in quarterly profit on strong sales of Internet phone gear and new deals with phone and cable companies.

Apple Computer Inc. (AAPL) weighed on the S&P index and the tech-heavy Nasdaq.

Apple shares were down 2.2 percent to $35.61 after Yahoo Inc. (YHOO) said on Tuesday it would launch an online subscription music service, rivaling services from Apple, Napster (NAPS) and RealNetworks Inc. (RNWK).

RealNetworks dropped 21 percent to $5.76 and Napster slid 26.8 percent to $4.65. Yahoo rose 2.4 percent to $34.88.

General Motors Corp. (GM) dragged on the Dow a day after its largest parts supplier, Visteon Corp. (VC), said it will delay filing its quarterly report as it investigates allegations of improper conduct by a senior finance employee.

GM shares were off 1.7 percent at $31, while Visteon sank 5.8 percent to $3.59.

Trading was moderate, with 1.4 billion shares changing hands on the New York Stock Exchange, just below the 1.46 billion daily average for last year. About 1.7 billion shares were traded on Nasdaq, below the 1.81 billion daily average last year.

The number of rising stocks outnumbered declining stocks by about 9-to-7 on the New York Stock Exchange. On Nasdaq, advancers and decliners were nearly even.

The Russell 2000 index of smaller companies was up 0.53, or 0.09 percent, at 595.57.

Overseas, Japan's Nikkei stock average fell 0.4 percent. In Europe, Britain's FTSE 100 was down 0.35 percent, Germany's DAX index was down 0.16 percent, and France's CAC-40 was down 0.52 percent.

Reuters and The Associated Press contributed to this report.