The New York Times said on Thursday that digital subscriptions topped 3-million in the past quarter, keeping the prestigious daily profitable in a difficult environment for the news media.

With a gain of 203,000 online-only subscribers in the third quarter, the newspaper is now getting nearly two-thirds of its revenue from subscriptions, helping to offset weakness in advertising and print circulation.

The Times posted a net profit of $24.9m in the quarter, down from $36m in the same period a year ago, as total revenues rose 8% to $417m.

“This was a strong third quarter for the company,” said Mark Thompson, president and CEO of The New York Times Company.

“We also passed two significant milestones, and now have more than 3-million digital-only subscriptions and more than 4-million total subscriptions.”

While its profits are modest, the Times has been among the most successful legacy news organisations navigating the transition to digital news amid sharp declines in print readership.

The Times has maintained a large newsroom staff and has invested aggressively, seeking readers internationally and stepping up coverage of Washington even as it faces attacks from US President Donald Trump.

New York Times shares are publicly traded, but the stock structure allows the controlling family to stave off the kinds of moves seen at other news organisations aimed at cutting costs to boost short-term profits.

The quarterly update showed a 7% year-on-year increase in advertising, led by digital. But ad revenues for the first nine months of the year are down 2.5% and the company said it expects flat advertising revenues in the fourth quarter.

According to the Times, revenue improved in part due to an agreement with Long Island daily Newsday to print and transport its publications, and the renting of four additional floors at the New York headquarters.