Boeing Co's quarterly profit beat expectations as operating margins improved and it contained costs, sending shares of the company higher.

The world's largest aerospace and defense company also raised its 2011 earnings forecast, but the range it gave was still slightly below the average Wall Street estimate.

Everybody is surprised by the size of the beat, but if you go through it, it's just cost containment and cost improvement, said Alex Hamilton, managing director of EarlyBirdCapital. He noted an operating margin of 9.3 percent, compared with 8.4 percent a year ago.

Boeing second-quarter profit was $941 million, or $1.25 per share, compared with $787 million, or $1.06 per share, a year earlier. The results topped a Wall Street consensus forecast for a profit of 97 cents per share, according to Thomson Reuters I/B/E/S.

Revenue rose 6 percent to $16.5 billion.

Boeing also said it raised its 2011 earnings-per-share forecast to a range of $3.90 to $4.10 from a previous forecast of $3.80 to $4.

Boeing, which competes with EADS unit Airbus, splits its business almost evenly between commercial airplanes and defense products.

But its stock tends to track commercial airplane orders and deliveries, which are recovering from an economic downturn curbed orders in recent years.

Also on Wednesday, the Commerce Department said new orders for long-lasting U.S. manufactured goods fell in June, supporting views that the economy will not emerge quickly from its current soft patch.

Orders last month were pulled down by an 8.5 percent drop in orders for transportation equipment. That reflected a 28.9 percent plunge in aircraft orders.

REBOUND ON COMMERCIAL SIDE

Boeing's commercial airplane revenue rose 19 percent in the quarter to $8.8 billion on higher deliveries. The company reported 118 commercial airplane deliveries in the quarter, up from 114 a year ago.

Boeing reaffirmed that first deliveries of the long-awaited 787 Dreamliner and 747-8 Freighter are expected later in the third quarter but trimmed its expected deliveries for the two programs to a combined 25 to 30 planes units from 25 to 40.

Boeing expects to deliver between 485 and 495 commercial planes this year, down from a previous prediction of 485 to 500.

The revisions in the 787 and 747-8 production schedules weren't as bad as many feared, and first deliveries appear to be on track, said Matt Collins, an analyst at Edward Jones.

After those initial deliveries take place, it's up to Boeing to execute on the production ramp up, as well as keeping costs down on the tanker program and moving forward with the 737 re-engine, he said.

Last week, Boeing announced plans to re-engine, or put a new, more fuel-efficient engine in its best-selling 737 narrow-body plane. The company debated for more than a year whether to re-engine or redesign the plane. A redesigned 737 would have taken longer to bring to market, but could have provided more fuel savings.

The plane maker had intended to take more time to decide, but its hand was forced by AMR Corp's American Airlines, a loyal Boeing customer, which was threatening to give an entire order to Airbus for the competing A320neo. In the end, AMR said it would buy 200 737s and 260 A320s.

Boeing's defense, space and security business reported revenue of $7.7 billion, down 4 percent from the year-ago quarter. The division predicted 2011 revenue in a range of $31.5 billion and $32.5 billion, down slight from a previous forecast of $31.5 billion to $33 billion.

Boeing said its total company backlog was $323 billion.

Shares of Boeing, a Dow component, were up 2.6 percent to $72 on the New York Stock Exchange.

(Reporting by Kyle Peterson, editing by Maureen Bavdek and Derek Caney)