By Drew FitzGerald

Verizon Communications Inc. continued to add cellphone customers as the coronavirus raged in the spring, though quarterly revenue declined in its core wireless business and its online advertising unit.

The largest U.S. cellphone carrier by subscribers on Friday reported a net gain of 173,000 postpaid phone connections during the three months through June. The figure included past-due accounts that were still in service in the quarter under a commitment by providers to grant leeway during the pandemic.

Verizon counted 119.9 million active wireless connections, which include tablets, smartwatches and other cellular devices, at the end of June.

U.S. wireless and broadband-service providers agreed earlier this year to waive late-payment and overage fees and maintain service for customers unable to pay their bills during a health crisis that had already forced tens of millions of Americans to work from home.

The federal Keep Americans Connected pledge expired June 30, putting hundreds of thousands of users at risk of losing service. But Verizon said it had enrolled many customers in extended repayment plans in July to keep them on its rolls.

"We believe the vast majority of these accounts can be cured over time," Chief Financial Officer Matt Ellis said during a conference call with analysts, though he warned that expectation hinges on the economic environment.

About 1.5 million personal and small-business accounts took advantage of the extra grace period for late payments in the second quarter, Mr. Ellis said, adding that most of them made some payment and roughly a third were current by the end of June.

Rival AT&T Inc. on Thursday reported a net loss of 151,000 postpaid phone subscribers, a figure that counted 338,000 past-due subscribers as disconnections, though their service remained active during the pledge.

Verizon, which temporarily closed its retail stores as the coronavirus spread across the U.S., said its device-upgrade rate fell to 3.7% from 4.3% a year earlier as weak retail traffic crimped smartphone sales. The company said more than 60% of its locations were open by the end of June and it expects to be almost fully open by the end of this month.

Overall, the company's total revenue for the second quarter slipped 5.1% from a year earlier to $30.4 billion. Wireless-service revenue fell 1.7%, and the company forecast it would be flat to down 1% in the current quarter. Revenue in the company's media business, which includes its Yahoo and AOL properties, fell 25% to $1.4 billion.

Net income attributable to Verizon rose to $4.7 billion, or $1.13 a share, from a year-earlier $3.9 billion, or 95 cents a share. Fewer phone sales helped boost Verizon's bottom line because devices sold to customers offer carriers little to no profit. Total equipment costs dropped 18%.

The Covid-19 pandemic upended companies' profit projections this spring and forced many to set aside more cash for unexpected expenses. Verizon earlier this year pulled its revenue guidance and lowered its projection for annual adjusted per-share profit to a range between 2% growth and a 2% decline. The company on Friday reiterated that prediction.

Executives have also said the essential nature of cellphone and broadband service could boost results during the pandemic, which has triggered a work-from-home wave. The company in April agreed to buy Blue Jeans Network Inc., a videoconferencing service that targets corporate clients.

The company's consumer unit reported a net gain of 10,000 Fios broadband subscribers despite a temporary pause in some in-home installations. Fios pay-TV customers dropped by 81,000 as more Americans cut the cable cord in favor of cheaper streaming video options.

Write to Drew FitzGerald at andrew.fitzgerald@wsj.com