Uber Technologies Inc on Tuesday reported positive quarterly cash flow for the first time ever and forecast third-quarter operating profit above estimates, betting on steady demand for its ride-hailing and food-delivery services.

Uber shares, which have lost more than 40% this year, surged 15% to $28.41 in premarket trading and helped drive an 8% gain in rival Lyft Inc's shares.

Uber generated free cash flow of $382 million in the second quarter, topping analysts' expectations of $263.2 million, as trips exceeded pre-pandemic levels, boosted by the reopening of offices and a surge in travel demand.

The number of drivers and delivery agents on its platform rose 31% to an all-time high of almost 5 million, allaying concerns that soaring gas prices was deterring them from signing up with the company.

"That's right: more people are earning on Uber today than before the pandemic," Chief Executive Officer Dara Khosrowshahi said.

Growth at its delivery business was slowing but Uber expected ordering in to become the standard for consumers as it continues to add new partners.

The delivery segment's revenue rose 37% to $2.69 billion, while that of ride-share business surged 120% to $3.55 billion in the quarter ended June 30.

Analysts were expecting revenue of $2.58 billion for delivery and $2.93 billion for ride share.

Gross bookings, or the total value of bookings made on its platform, rose 33% to $29.1 billion.

Adjusted EBITDA was $364 million, surpassing estimates of $257.89 million.

It now expects adjusted EBITDA of between $440 million and $470 million for the third quarter, well above analysts' forecast of $383.95 million, according to IBES data from Refinitiv.

(Reporting by Nivedita Balu in Bengaluru; Editing by Anil D'Silva)