Twitter Inc on Friday blamed its ongoing battle to close its $44-billion acquisition by Elon Musk and a weakening digital advertising market for a surprise fall in quarterly revenue and a net loss.

The results come as Twitter has sued Musk for dropping his offer to buy the company, and is now preparing for a legal showdown in a trial set to begin in October. The deal uncertainty has worried Twitter's advertisers and caused chaos inside the company.

Advertising revenue rose just 2% to $1.08 billion, missing Wall Street expectations of $1.22 billion, according to Refinitiv IBES data.

Total second-quarter revenue, which also includes revenue from subscriptions, was $1.18 billion, compared with $1.19 billion a year earlier. Analysts were expecting $1.32 billion.

"Twitter is now in the unenviable position of convincing advertisers that its ad business is solid regardless of how its court battle with Musk ends, and its Q2 earnings show that the platform has its work cut it out for it to do that," said Jasmine Enberg, principal analyst at research firm Insider Intelligence.

Twitter shares were down 1.8% in trading before the bell.

Twitter said its net loss was $270 million, or 35 cents per share, versus a profit of $65.6 million, or 8 cents per share, a year earlier.

Its adjusted 8-cent loss missed expectations for a 14-cent adjusted profit.

Monetizable daily active users, a metric closely watched by investors and measures users who see advertising on Twitter, grew 16% to 237.8 million, but missed analyst expectations of 238.7 million.

The San Francisco-based company said bot and spam accounts represented fewer than 5% of users during the quarter, a figure it has repeated since 2013.

Musk has seized on the proportion of bot and spam accounts as his reason for backing out of the deal, accusing Twitter of withholding information on the true number of such accounts on the service.

The company's costs and expenses jumped 31%. Expenses related to the Musk deal totaled $33 million during the quarter, and also recorded $19 million in severance-related costs.

Inflation pressures and fears of a recession this year have forced some advertisers to slash their marketing budgets.

On Thursday, Snapchat parent Snap Inc posted weak revenue growth and declined to make a forecast, citing "incredibly challenging" conditions as advertisers cut back on spending.

(Reporting by Nivedita Balu in Bengaluru and Sheila Dang in Dallas; Editing by Saumyadeb Chakrabarty and Nick Zieminski)