Charles Schwab ( SCHW) shares rallied as much as 9.6% Wednesday after the brokerage reported sliding first-quarter profits but beat Wall Street's expectations.

The San Francisco-based brokerage made $218 million, or 19 cents a share, a 29% drop from the $305 million, or 26 cents a share, in the year-earlier period. Revenue fell 15% to $1.11 billion.

The first quarter results were aided by a $26 million pre-tax gain related to Schwab's repurchase of $64 million in outstanding debt. But it also included $14 million related to an impairment charge on mortgage-backed securities collateralized by Alt-A mortgages owned in the firm's investment portfolio and a pre-tax charge of $59 million related to severance and other costs as part of the company's previously announced expense reduction plan, it said.

Still Schwab beat analysts' expectations on earnings by 4 cents a share. The company's revenue also came in slightly above analysts' revenue expectations.

"Our business is about serving our valued clients -- and they stayed actively engaged with us in the first quarter," CEO Walt Bettinger said. "Although the market environment remained challenging for investors, the latter part of the quarter did show some glimpses of improvement."

The company brought in $25.3 billion in net new assets during the quarter, down 39% from a year earlier and 17% from the fourth quarter.

Total client assets totaled $1.099 trillion at the end of the quarter, down 21% from a year earlier and down 3% from the fourth quarter.

If you liked this article you might like

Massachusetts Opens Inquiry Into 7 Brokerage Firms

Charles Schwab, SAP, Nike, General Electric: 'Mad Money' Lightning Round

Old Dogs Are Learning New Tricks: Cramer's 'Mad Money' Recap (Wednesday 7/26/17)

Goldman Sachs' Culture of Secrecy Draws New Skepticism After Trading Gaffe