SAN FRANCISCO — Twitter is still turning a profit — but it is continuing to have trouble holding on to its users.

On Thursday, the social networking service said it had 326 million monthly active users, down nine million over the last three months and four million from a year ago. It was the second consecutive quarterly user decline for the company, even as President Trump and other public figures regularly take to Twitter to express their views and engage their followers.

Despite the fall in users, Twitter said its third-quarter revenue rose 29 percent from a year earlier, to $758 million. Net income totaled $789 million, compared with a loss a year earlier, in what was the fourth straight quarter of profits for the company. (Excluding a tax-related accounting gain, the quarter’s profit amounted to $106 million.)

Investors did not seem to mind the drop in monthly users: Twitter’s stock rose 15.5 percent on Thursday.