(Bloomberg) -- The two Wall Street firms most tied to dealmaking are getting rewarded for gaining ground.

Morgan Stanley and Goldman Sachs Group Inc. both said on Tuesday that their investment banking businesses surged, despite a slump at every other rival. Both banks were helped by a boom in initial public offerings, and their debt-underwriting units weathered a slowdown better than the larger peers.

The two firms are starting to look more like traditional lenders as they offer personal loans to consumers and mortgages to wealthy individuals. But fees from advising on mergers and underwriting securities still make up a bigger portion of their revenue than at commercial banks. Shares of both companies jumped after their investment banking results led to better-than-expected profit.

"Banking results are extremely strong, this is our best third quarter," Morgan Stanley Chief Financial Officer Jonathan Pruzan said in a phone interview. He said the gains came from "strengthening relationships, gaining share and the global footprint working."

Morgan Stanley’s investment-banking revenue surged 15 percent, and the business was up 10 percent at Goldman. JPMorgan Chase & Co., Citigroup Inc. and Bank of America Corp. posted declines.

At Goldman Sachs, the results were a boon to new Chief Executive Officer David Solomon, who ran the investment-banking unit for a decade before rising to the top job. Morgan Stanley benefited from a surprise jump in debt underwriting -- the only rise on Wall Street -- and said the bank’s pipeline for mergers and acquisitions is strong for the rest of the year.

Morgan Stanley shares climbed as much as 5.3 percent, the most since February 2017, and were up 4.4 percent at 11:40 a.m. in New York. Goldman Sachs’s stock rose 1.4 percent.

Mergers and acquisitions advice wasn’t the bright spot. Fees were roughly unchanged at Goldman, and they slipped at Morgan Stanley. There are concerns among investors that dealmaking could be damped as trade tensions and market volatility weigh on large-scale transactions. Announced M&A volumes of more than $3 trillion globally through the end of the third quarter had given 2018 a chance to set a record for deals.

The outlook for dealmaking is unclear. Trade tensions between the U.S. and China may challenge some key areas of growth. Asia’s equity exchanges are "down pretty dramatically," Pruzan said, after strong equity underwriting in the region earlier in the year. Cross-border dealmaking may also be affected. Goldman Sachs said its backlog was lower compared with the end of the second quarter.

But the two firms showed they could post gains even in a down overall market for fees, which could help them narrow this year’s stock declines, the worst among major banks. Goldman CFO Marty Chavez said the firm is making steady progress in its goal to cover 1,000 new corporate clients.

“There’s a disconnect between perception of the cycle coming to an end and these companies telling us that things feel constructive," said Devin Ryan, a bank analyst at JMP Securities LLC.

--With assistance from Yalman Onaran.

To contact the reporters on this story: Sonali Basak in New York at sbasak7@bloomberg.net;Sridhar Natarajan in New York at snatarajan15@bloomberg.net

To contact the editors responsible for this story: Michael J. Moore at mmoore55@bloomberg.net, Daniel Taub

©2018 Bloomberg L.P.