Apple Inc on Tuesday beat revenue and profit expectations in its March quarter as it sold 52.2 million iPhones, barely below Wall Street targets and showing some resilience as global demand for smartphones wanes.

The company also predicted a revenue range of $51.5 billion to $53.5 billion for the June quarter, with a midpoint ahead of the $51.6 billion Wall Street expected.

Apple also boosted its capital return program by $100 billion, with repurchases from the increase set to begin in the June quarter, and said it bought $23.5 billion of stock back in the March quarter, a sign that it is bringing back most of its hundreds of billions of dollars in cash to the United States.

The share repurchases in the march quarter drove Apple's cash net of debt down slightly to $145 billion.

"We are returning the cash to investors as we have promised,” Chief Financial Officer Luca Maestri told Reuters in an interview.

The results sent Apple shares up 3.7 percent to $175.50 in after-hours trading.

Apple has been at a challenging crossroads this year with sales of its flagship iPhone X disappointing many observers. Investors have watched Apple closely in recent weeks as a string of poor forecasts from the smartphone supply chain signaled that iPhone demand may be lower than previously expected. They have also been watching carefully for signs of what Apple plans to do with its hundreds of billions of dollars in cash.

Apple posted revenue for its March quarter of $61.1 billion, up from $52.9 billion last year. Wall Street expected $60.8 billion, according to Thomson Reuters I/B/E/S. The company sold 52.2 million iPhones versus expectations of 52.3 million, according to data from Thomson Reuters I/B/E/S, up from 50.7 million last year.

Average selling prices for iPhones were $728, compared with Wall Street expectations of $742. Maestri told Reuters that the company's seasonal drawing down of iPhones sitting on store shelves accounted for some of the difference because it was concentrated on higher-end iPhone models this year. Profits were $2.73 per share versus expectations of $2.68 per share and up from $2.10 a year ago.

The company forecasted a midpoint of $52.5 billion in revenue for the June quarter, beating analyst expectations of $51.6 billion.

Apple's services business, which includes Apple Music, the App Store and iCloud, posted $9.1 billion in revenue compared with expectations of $8.3 billion. Heading into earnings, investors were hopeful that growth in that segment could help offset the cooling global smartphone market.

Apple traditionally updates its share buy-back and dividend program each spring, and the $100 billion it added this year compares with an increase of $50 billion last year. The company also increased its quarterly dividend 16 percent, compared with a 10.5 percent increase last year.

In February, Apple said it planned to draw down its excess cash, though Chief Executive Tim Cook had downplayed the possibility of a special dividend. But investors have had concerns around Apple because of a brewing trade tensions with China. While there has not yet been a tariff on devices such as Apple's iPhone, Cook last week traveled to Washington to meet with U.S. President Donald Trump at the White House to discuss trade matters.

"We believe tariffs at the end of the day are a tax on the consumer," Maestri said.

Apple has been emphasizing its contributions to the U.S. economy in recent months, outlining a $30 billion U.S. spending plan and highlighting the tens of billions of dollars it spends each year with U.S.-based suppliers.

In recent months, Apple has been emphasizing the size of its overall user base, which includes used iPhones, rather than focusing strictly on new device sales, a sign of the increasing importance of making money off users without selling them new hardware.

Apple shares have dropped 0.1 percent this year and closed at $169.10 on Tuesday, down 1.8 percent from their price of $172.26 at the start of the year. Their performance lags the NASDAQ Composite Index, which was up 3.3 percent for the year.

- Reuters