Twitter Inc. reported a surprising decline in revenue that the social-media company blamed on advertising weakness and uncertainty related to its pending $44 billion acquisition by Elon Musk.

Twitter’s results Friday follow rival social-media company Snap Inc. posting its weakest-ever quarterly sales growth because of what it said was “increasing competition for advertising dollars that are now growing more slowly.”

Twitter, in its news release, cited “advertising industry headwinds associated with the macroenvironment as well as uncertainty related to the pending acquisition of Twitter.” The company won’t host an earnings conference call because of the pending transaction, which it is suing Mr. Musk to complete.

Twitter’s revenue dipped to $1.18 billion from $1.19 billion a year ago, and was below the average analyst estimate of $1.32 billion on FactSet.

Advertising revenue rose 2% from a year earlier to $1.08 billion. In the first quarter, advertising revenue grew 23%.

Twitter’s slowdown in ad revenue suggests the turmoil surrounding Mr. Musk’s deal is irking advertisers, said Truist Securities analyst Youssef Squali. “Advertisers don’t even want to deal with Twitter until they know what’s going on,” he said. The company is “caught in the middle of a nightmare.”

Elon Musk has questioned Twitter’s user numbers.

Photo: jim watson/Agence France-Presse/Getty Images

Shares of Twitter were down around 1% in midday Friday trading. In comparison, Snap shares were down around 38%.

Mr. Musk’s $54.20-a-share bid for Twitter has helped hold up the company’s stock price amid a sharp selloff in tech company stocks. Twitter’s stock price was down less than 10% so far this year, while the tech-heavy Nasdaq Composite Index has lost more than 20%.

Twitter reported a loss of $270 million, or 35 cents a share, compared with year-ago earnings of $65.6 million, or 8 cents a share. Excluding items like stock-based compensation, the company reported an adjusted loss of 8 cents a share. Analysts, on average, were expecting an adjusted profit of 14 cents a share, FactSet shows.

The Twitter Headquarters in San Francisco, Calif.

Photo: Ian Bates for The Wall Street Journal

The number of Twitter’s monetizable average daily active users increased to 237.8 million from 229 million in the first quarter and 206 million a year ago. U.S. users—who make up the company’s biggest market—grew to 41.5 million from 39.6 million in the first quarter and 37 million a year ago. The company said the increase was driven by product improvements and global conversation around current events.

Modest increases in Twitter’s user base aren’t enough to excite advertisers at a time when the company is in a legal battle over its fate, said Benchmark analyst Mark Zgutowicz.

“Twitter’s been focused on Elon over the last quarter. It’s an easy reason for advertisers to shift their spend away from Twitter,” he said.

At the release of its results in April, Twitter said that it was withdrawing earlier goals and outlooks and that it wouldn’t provide forward-looking guidance. Before Mr. Musk’s courtship, Twitter had been working to achieve three main goals by the end of 2023: to surpass $7.5 billion in annual revenue, reach 315 million daily users and double the pace at which it produces new technology.

Earlier this week, Delaware Chancery Court’s chief judge granted Twitter’s request to fast-track its lawsuit against Mr. Musk. A five-day trial is scheduled for October despite opposition from the billionaire’s lawyers, who argued that a trial should take place on or after Feb. 13 of next year.

Mr. Musk has said his primary reason for backing out of the deal is a lack of faith in Twitter’s estimate that less than 5% of its monetizable daily active users are spam or fake accounts. He has said that estimate is probably too low.

Twitter has said for years in its securities filings that the number of fake and spam accounts on its platform could be higher than its estimates. The company said in its lawsuit against Mr. Musk that he has buyer’s remorse over the fall in share prices since he agreed to the deal in April.

In a recent court filing, Mr. Musk’s team said they became concerned about Twitter’s user numbers after the company disclosed in its April earnings report that it had overstated its user base for nearly three years through the end of 2021 because of an error in how it accounted for people linked to multiple accounts. The revision reduced the number of monetizable daily active users by 0.9% for the fourth quarter of last year.

SHARE YOUR THOUGHTS

What do you think about Twitter’s most recent earnings report? Join the conversation below.

The court filing also said that Mr. Musk met with Twitter executives in May to discuss how the company measures spam and that he was “flabbergasted to learn just how meager” its process was and pointed to the absence of automated tools to help with the calculation.

Write to Sarah E. Needleman at sarah.needleman@wsj.com