Tim Cook, chief executive officer of Apple Inc., center, hugs an employee during the sales launch for the iPhone 6 and iPhone 6 Plus at the Apple Inc. store in Palo Alto, California, U.S., on Friday, Sept. 19, 2014. Apple Inc.'s stores attracted long lines of shoppers for the debut of the latest iPhones, indicating healthy demand for the bigger-screen smartphones. The larger iPhone 6 Plus is already selling out at some stores across the U.S. Photographer: David Paul Morris/Bloomberg via Getty Images

Apple sold a record 5.52 million Macs in the three-month period that ended in September, up 21 percent from the same period last year, the company said Monday.

"It was just an absolutely blow-away quarter. Our best ever," Tim Cook, Apple's CEO, said on a call with investors. "It's just absolutely stunning."

News of strong Mac sales comes as PC sales have declined in recent years, as people have opted for smartphones and tablets instead of desktops and laptops. According to IDC, the technology research firm, the worldwide PC market was down 1.7 percent last quarter from the same period the year before.

"Being up 21 percent in a market that's shrinking -- it just doesn't get better than that," Cook said during the call.

IDC reported earlier this month that Apple had a 6.3 percent share of the worldwide PC market last quarter, placing it fifth among manufacturers, after Lenovo, HP, Dell and Acer. Cook said Apple had its highest quarterly share of the PC market since 1995.

Data for chart courtesy of Benedict Evans of Andreessen Horowitz.

Cook attributed the surge to back to school shopping, and called out college students specifically.

"I think if you went out to college campuses about now, you would see a lot of new new Mac notebooks there," Cook said.

Sales may also be up thanks to the runaway success of the iPhone, which may be attracting new customers to Apple's ecosystem.

Apple sold a record 39.27 million iPhones in the quarter, up 16 percent from the same period last year.

iPad sales continued to slip, down 13 percent from last year. Less-expensive Android tablets, and the fact that people don't upgrade tablets as frequently as they upgrade their phones, have eaten into sales.

Some people may even be opting for Macs instead of iPads.

"I'm sure that some people looked at a Mac and an iPad and decided on a Mac," Cook said on the call.