NEW YORK — After much hype leading up to the largest initial public offering in five years, Uber hit a few potholes on its first day of trading, closing down 8% and reflecting lingering doubts about its future prospects for profitability.

The ride-hailing company injected investors with a dose of reality right out of the gate, trading at $42 a share Friday — or nearly 7% below its IPO price of $45 on an already volatile day for the markets. Its shares closed at $41.57.

Despite the rocky debut, Uber CEO Dara Khosrowshahi said he was thrilled to complete the IPO, adding that the $8.1 billion that Uber raised in the process would be crucial to its future growth plans.

"It's a great moment for the company and all the employees who have been working so hard to get here," Khosrowshahi said in an interview with The Associated Press. "It was a tough week to go public, but we got it done."

Uber's IPO price was lower than initially expected, and the caution may have been driven by escalating doubts about the ability of ride-hailing services to make money since Uber's main rival, Lyft, went public six weeks ago.

Jitters about an intensifying U.S. trade war with China also contributed. Stocks were down sharply Friday morning after the two countries failed to reach a deal before a tariff deadline, but finished with gains.

Despite the volatile market, Khosrowshahi said he did not consider postponing Uber's IPO date.

"Our company is not a fair-weather company," Khosrowshahi said. "We keep moving forward in tough and easy environments, and I think that we as a company will be a great investment over the long term."

It's not the first time a company's stock has started off trading below its IPO price, not even this week. On Thursday, Axcella Health began trading well below its $20 IPO price and ended its first day at $13.80.

But it's relatively uncommon for U.S. technology companies backed by venture capital, like Uber. Over the past five years, just 10% of such companies finished their first day of trading below their IPO price, said Matt Kennedy, senior IPO market strategist at Renaissance Capital, a manager of IPO focused funds.

"We were not expecting much of a pop, given the size of the deal" for Uber, Kennedy said. "The last U.S. company of this size to IPO was Facebook, for example, and you may remember how that traded initially."

Facebook debuted in 2012 and, after technical difficulties delayed its start to trading, it ended its first day just 23 cents above its IPO price of $38.

"Unlike Facebook, however, Uber does not make money," Kennedy said. Facebook's stock now trades just below $200.

Investors say they're hesitant to buy Uber's stock out of the box because of what happened with Lyft, and want to see it settle before buying significant amounts of shares, said Dan Ives, managing director of equity research at Wedbush Securities.

Lyft's shares were down 7% to $51.09 Friday, or 29% below its IPO price of $72. But even with Uber's lower share price, its valuation of $76 billion is four times more than Lyft's.

Uber's cash infusion will help cover the cost of giving rides to passengers at unprofitable prices as it tries to fend off competition from Lyft. The San Francisco company already has lost about $9 billion since its inception in 2009 and acknowledges it could still be years before it turns a profit.

That sobering reality is one reason that Uber fell short of reaching the $120 billion market value that many observers believed its IPO might attain.

Despite all that, Uber's IPO is the biggest since Chinese e-commerce giant Alibaba Group debuted in 2014. Uber's revenue last year surged 42% to $11.3 billion while its cars completed 5.2 billion trips around the world either giving rides to 91 million passengers or delivering food.

Uber might be even more popular if not for a series of revelations about unsavory behavior that sullied its image and resulted in the ouster of Travis Kalanick as CEO nearly two years ago.

The self-inflicted wounds included complaints about rampant internal sexual harassment , accusations that it stole self-driving car technology, and a cover-up of a computer break-in that stole personal information about its passengers. Some Uber drivers have been accused of assaulting passengers, and one of its self-driving test vehicles struck and killed a pedestrian in Arizona last year while a backup driver was behind the wheel.

Uber hired Khosrowshahi as CEO to replace Kalanick and clean up the mess, something that analysts say has been able to do to some extent, although Lyft seized upon the scandals to gain market share.

Both Kalanick and Uber's other co-founder Garrett Camp were present at the stock exchange Friday but absent from the podium during the bell ringing. Kalanick remains on Uber's board and while he kept a relatively low profile during the stock debut, he can still savor his newfound wealth. As of Friday's closing price, his stake in Uber will be worth $4.9 billion. Hundreds, if not thousands, of other Uber employees are expected to become millionaires in the IPO.

Meanwhile, scores of Uber drivers say they have been mistreated by the company as they work long hours and wear out their cars picking up passengers as they struggle to make ends meet.

SharesPost principal analyst Alejandro Ortiz said the timing for Uber to start trading was bad given the uncertainty over the trade spat with China. But Uber's story can't be just one day of trading because of its potential to make billions in a growing ride market, he said.

"It's going to keep bouncing around for months to come," Ortiz said. "It's an important thing to consider if you're an investor and you saw value in the company and its disruptive potential, nothing has really changed in the past 48 hours."

__

Liedtke reported from San Francisco and Krisher reported from Detroit. AP Business Writer Stan Choe in New York contributed to this report.