By Maria Armental

Costco Wholesale Corp. reported a better-than-expected 13.2% comparable-sales increase in July, delivering a boost to its stock that's been trading at record levels.

Shares, which closed at a record $339.97 on Wednesday, rose 1% in after-hours trading.

The warehouse operator, one of the companies whose services were deemed essential and remained open during the coronavirus pandemic, had initially seen a surge in demand as customers stockpiled--and cleaned out shelves.

On Wednesday, Costco reported $13.04 billion in net sales for the four weeks ended Aug. 2, a 14% increase from the comparable period a year earlier, while comparable sales rose 13.2%. Excluding the impact from gasoline sales and currency swings, core comparable sales rose 15.8%. Analysts surveyed by Consensus Metrix expected a 7.6% increase, or 10% when adjusted for gas sales and currency swings.

Costco, which has 790 warehouses, has put in place temporary restrictions during the pandemic, including setting aside a shopping time for those 60 or older and giving priority access to health-care workers and first responders like police officers, EMTs and firefighters. It requires all shoppers and workers to wear face coverings to help curb the spread of the virus, with the exception of toddlers under the age of 2 or those unable to wear face coverings for medical reasons.

Write to Maria Armental at maria.armental@wsj.com