By Liza Lin and Dave Sebastian

Alibaba Group Holding Ltd. said fiscal first-quarter profit more than doubled from the same period a year ago, as the coronavirus outbreak led to more shoppers buying daily necessities and other products online.

Alibaba, China's most valuable technology company, reported net income of 47.6 billion yuan ($6.7 billion) for the quarter ending June. It also said revenue rose 34% to 153.8 billion yuan, exceeding expectations of 148 billion yuan by analysts polled by FactSet.

The Hangzhou-based technology giant, which runs two of China's most popular e-commerce websites, benefited from a shift in consumers' shopping habits after the coronavirus outbreak earlier in the year led more Chinese to shop online. China's economy also rebounded from a contraction in the first three months of 2020, growing more than 3% in the second quarter, making it the first major economy to return to growth since the start of the pandemic.

"The coronavirus has been good for Chinese e-commerce players," said Steven Zhu, an analyst at research firm Pacific Epoch, who added that the outbreak accelerated a move by older consumers and those in smaller Chinese cities to shift their buying from physical stores to online platforms. "Once you switch, you don't switch back."

Thursday's results mark a recovery from a tepid January-to-March earnings quarter, when Alibaba's profits tanked as the pandemic affected the value of its public investments. Earnings in that quarter fell 88%. Beyond its retail marketplaces, the company also runs a cloud services division and digital media platforms.

Even so, Chinese consumer spending remains relatively strong. Alibaba, which counts more than 800 million monthly active users on its mobile retail platforms, reported China commerce retail sales grew 34% from a year ago to 101 billion yuan.

"Our domestic core commerce business has fully recovered to pre-Covid-19 levels across the board," Alibaba's Chief Financial Officer Maggie Wu said in a statement Thursday.

As the coronavirus led to widespread city lockdowns earlier this year, more Chinese consumers turned to e-commerce and their platforms to buy fresh food and groceries online to cook at home, Daniel Zhang, Alibaba's chairman and chief executive officer, told investors in May. This helped offset a drop in spending on clothing and cosmetics, he said.

In the June quarter, the company also benefited from a midyear shopping festival for which it ran numerous marketing campaigns and dangled promotions to encourage spending.

The company has also introduced new ways to market its products to fight off competition from its rivals such as JD.com Inc., including live-streaming product demonstrations and sales pitches.

Another bright spot for the Chinese technology juggernaut was its loss-making cloud-computing division. Revenue in the segment grew 59% to 12.3 billion yuan in the quarter as more businesses ramped up efforts to digitize their operations. Alibaba's digital media and entertainment unit also posted a 9% rise in sales for the June quarter.

Adjusted earnings per American depositary share were 14.82 yuan. Analysts polled by FactSet were expecting 13.82 yuan a share.

Despite the strong showing, analysts say geopolitics and a fast ramp-up in the animosity between the U.S. and China continues to loom over on Alibaba's operations. Earlier this month, President Trump issued executive orders barring firms and people in the U.S. from transactions with Tencent Holdings Ltd.'s WeChat and Bytedance Inc.'s TikTok apps starting Sept 20. President Trump has said he is considering extending the ban to other Chinese companies.

Analysts from JPMorgan Chase & Co. said in an August report that geopolitical friction between the two major economies may negatively impact the growth of Chinese internet companies such as Alibaba, Tencent Holdings and NetEase Inc. in the mid-to-longer term as they face hurdles to international expansion. Chinese companies may divert their growth efforts inward instead, leading to more aggressive competition and lower industry profits within China, they wrote.

Write to Liza Lin at Liza.Lin@wsj.com and Dave Sebastian at dave.sebastian@wsj.com