Charles Schwab Corp , the largest U.S. discount brokerage, on Friday posted slightly higher-than-forecast earnings as rising stock markets led to increased trading and fees from clients.

Net income for the three months ended March 31 was $243 million, or 20 cents per share, compared with $6 million, or nil per share, in the year-earlier quarter, when a legal settlement nearly wiped out earnings.

Revenue at San Francisco-based Schwab rose to $1.21 billion from $978 million, helped by higher stock markets that generated more trading and fees on invested assets. The Standard & Poor's 500 index rose 4.2 percent in the first quarter.

Analysts, on average, forecast earnings of $225.8 million, or 19 cents per share, on revenue of $1.18 billion, according to Thomson Reuters I/B/E/S.

Rising stock markets have attracted more retail customers to Schwab and led to greater inflows into Schwab mutual funds. But competition from online brokers TD Ameritrade Holding Corp , E*trade Financial Corp and independent broker-dealers has led Schwab to lower prices for trades, hampering revenue growth.

Shares of Schwab, which is highly sensitive to interest rate movements, have gained 4.1 percent this year, partly on expectations that rising interest rates would widen net interest margins and restore fees waived on low-yielding money market funds.

(Reporting by Philipp Gollner, editing by Gerald E. McCormick, Dave Zimmerman)