The results far exceeded the expectations of Wall Street analysts. They had expected $1.07 cents a share and revenue of $6.96 billion, according to a survey of analysts by Bloomberg.

Image Steven P. Jobs, Apples chief executive, said increased traffic at the companys retail stores led to stronger sales. Above, the reflection in an Apple Store window in San Francisco on Wednesday. Credit... Justin Sullivan/Getty Images

The company, based in Cupertino, Calif., also forecast strong sales in the coming months. Peter Oppenheimer, Apple’s chief financial officer, said the company expected third-quarter revenue of about $7.2 billion and earnings of about $1 a share.

Apple’s stock has declined 17.9 percent since the beginning of January when it peaked near $200 a share. After drifting below $120 a share, the stock has begun to recover since March. Shares on Wednesday closed up, rising $2.69 to $162.89, but then declined 26 cents, to $162.63 in after-hours trading over concerns that Apple’s profit margins were weaker than analysts expected.

If there is a weak spot in the company’s battle plan, it may be the iPhone smartphone, which has had stellar sales in the United States, but has showed weakness in Europe. Apple said it sold 1.7 million iPhones for the quarter. “In my mind iPhone sales were soft,” said Charles Wolf, a financial analyst at Needham & Company. “It’s a question of the distribution model and of the price. The price clearly has to come down.”

Apple’s executives said the sales of iPhones exceeded internal company projections during the quarter.

Analysts and the industry are expecting Apple to introduce a higher performing version of the iPhone within the next two months, made for faster 3G data-oriented cellular networks. Mr. Jobs is under pressure to meet his 10 million iPhone sales forecast by the end of 2008. To meet that goal the company needs a second-generation iPhone, and it may also need to push the price of the existing $399 iPhone down significantly or introduce a stripped-down model.

Analysts have said that as the second quarter progressed, demand for Apple’s iPhone increased and that the computer maker was unable to keep up with demand. The supply issue could have been affected by the limited availability of 16-gigabyte flash memory chips, Mr. Wolf speculated.