(Reuters) - Shares of Apple Inc AAPL.O rose 3 percent on Wednesday after the company's quarterly report and current-quarter iPhone sales forecast calmed investor nerves about a potential slowdown in sales of its flagship product.

FILE PHOTO: A visitor uses her iPhone X to take a photo of Apple Park t-shirts at the new Apple Visitor Center in Cupertino, California November 17, 2017. REUTERS/Elijah Nouvelage/File Photo

Shares in the Cupertino, California firm had fallen 5 percent, or more than $40 billion in market value, in the two weeks before the report, thanks largely to a soft outlook from Taiwan Semiconductor Manufacturing Co Ltd 2330.TW which was read as pointing to weak demand for iPhones.

Yet while investors were bracing for weak smartphone sales, Apple sold 52.2 million iPhones, just shy of analysts’ estimate of 52.3 million.

At least four brokerages raised their price targets for Apple stock. Of 43 analysts covering, 29 have a “buy” or higher rating and 14 on “hold”. No one has a “sell” rating.

“iPhone unit sales were better than feared with our recently lowered estimates, and management highlighted consistent results in every geography with the iPhone X the top selling iPhone each week of the quarter,” Canaccord Genuity analyst T. Michael Walkley said.

Two other analysts estimated Apple would sell about 40 million iPhones in the current quarter, based on Apple’s June quarter revenue forecast of $51.5 billion to $53.5 billion and shares in Apple parts suppliers were also broadly higher.

Shares of AMS AMS.S, which provides the facial recognition technology used in Apple's iPhones, rose as much as 8 percent on Wednesday morning.

Those in Cirrus Logic CRUS.O, Skyworks Solutions SWKS.O, Lumentum Holdings LITE.O, Broadcom AVGO.O and Qualcomm QCOM.O were all gainers.

“While forecasted iPhone shipments of 39 million units is lower than our 42 million estimate a month ago, it’s far better than our 34 million estimate which reflected the weaker June quarter outlook from suppliers like TSMC and AMS,” Morgan Stanley analyst Katy Huberty said.

The $999 iPhone X, which features an edge-to-edge display and facial recognition technology to unlock the phone, has been plagued by supply bottlenecks and concerns about weak sales since it went on sale in November in the United States.

While Apple’s iPhone sales were marginally lower than consensus forecasts, its quarterly results still beat Wall Street targets, helped by a $9.1 billion revenue contribution from Apple’s services business.

“Services sales growth of 31 percent Y/Y was robust this quarter, and well above expectations, reflecting broad strength across Apple’s offerings, including App Store, Apple Music, iCloud and Apple Pay,” Deutsche Bank analyst Sherri Scribner said.

Apple also promised to hike its dividend by 16 percent and to buyback $100 billion worth of additional stock, which analysts said would create a floor for shares.

After a solid quarter that quashed most concerns about a slowdown, eyes will now turn to the next generation of iPhones to be launched in September.

“With our belief Apple will launch an iPhone X plus type combined with new improved features for the current sized iPhone X product, we believe Apple’s iPhone franchise will extend strong sales of higher-priced iPhones through C2019,” Walkley said.

Apple shares were trading at $175.60 on Wednesday morning.