Revenue at Robinhood Markets Inc. more than doubled in the second quarter thanks to a torrent of customers trading cryptocurrency, but the company posted a big loss due to an emergency funding deal earlier this year.

The trading app recorded a loss of $502 million, or $2.16 per share, on revenue of $565 million in its first earnings report since its July initial public offering. In the second quarter of 2020, Robinhood generated a profit of $58 million on revenue of $244 million.

Nearly 14.2 million Robinhood users, or roughly 63% of the company’s customer base with funded accounts, traded digital assets in the second quarter. Robinhood earned $233 million in fees from routing customers’ cryptocurrency trades to high-speed trading firms, with dogecoin accounting for nearly two-thirds of the volume. That is up from just $5 million a year earlier.

That helped offset slowdowns in other parts of Robinhood’s business due in part to waning interest in meme stocks. For instance, fees Robinhood earned executing customers’ stock trades fell 27% to $52 million.

Despite decreased stock-trading activity, interest that Robinhood received on margin loans nearly tripled to $31 million. Around 700,000 users held about $5.4 billion in margin-loan balances at the end of June.

SHARE YOUR THOUGHTS

What’s your outlook for Robinhood? Join the conversation below.

More than 300,000 Robinhood users purchased shares in the company’s IPO through its own app. It was the seventh new listing that Robinhood let its users buy into at the IPO price.

Chief Executive Vlad Tenev said on an earnings conference call that those offerings were oversubscribed by a factor of five. For the two IPOs that Robinhood offered on its app during the second quarter, medical-scrub maker FIGS Inc. and identity company Clear Secure Inc., users held around 80% of the shares they received 30 days afterward.

“Customers that have been participating in these IPOs have been relatively diamond-handed, so to speak,” said Mr. Tenev, referring to a popular term on trading message boards to describe investors who hold on to stocks for the long term.

Robinhood reiterated its third-quarter outlook for lower revenue and fewer new accounts, citing a typical trading lull in the late summer and early autumn.

Write to Peter Rudegeair at Peter.Rudegeair@wsj.com