NEW YORK (Fortune) -- JPMorgan Chase is grabbing a bigger slice of a smaller dealmaking pie -- leaving less for rival Bank of America.

New York-based JPMorgan (JPM, Fortune 500) was the biggest fee earner on Wall Street in the first half of 2009, according to figures released Thursday by markets data firm Dealogic.

JPMorgan generated $2.4 billion in fees for arranging stock and bond sales and mergers worldwide, Dealogic said. That's down 2% from a year ago.

A small year-over-year drop would hardly be worth celebrating in a typical year. But with Wall Street in steep decline -- industrywide fees dropped 30% in the first half, Dealogic said -- JPMorgan's performance stands out.

JPMorgan was the leading arranger of debt and equity offerings in the first half, displacing last year's No. 1 underwriter, the combination of Bank of America and Merrill Lynch. BofA Merrill fell to second in debt underwriting and fourth in equity underwriting. Its fees plunged 45% from the first half of last year.

The first half declines aside, BofA is hardly starving. BofA earned underwriting fees of $1.6 billion, in the first half, according to Dealogic data.

Neither JPMorgan Chase nor BofA was able to supplant Goldman Sachs (GS, Fortune 500) as the top mergers and acquisitions adviser, though. JPMorgan was second and BofA fifth this year -- the same as last year. Goldman was second in fees over all, raking in $1.7 billion -- down 23% from a year ago.

JPMorgan's gains came as merger activity and equity issuance slowed along with the global economy, in spite of a flurry of second-quarter debt and equity sales tied to the bank stress tests and Troubled Asset Relief Program repayments.

Worldwide stock sales in the first half were at their lowest level since 2005, while M&A volume plunged 36% from a year earlier, Dealogic said. The weak equity numbers came despite a record number of follow-on stock offerings as financial firms raised capital.

Still, more than half of JPMorgan's total fee windfall -- $1.3 billion -- came from equity underwriting, Dealogic said.

Nothing succeeds like success

Analysts have been gushing about JPMorgan's success during the financial crisis of the past two years. Led by CEO Jamie Dimon, the bank has benefited from the tumult, having been chosen by the government to buy troubled rivals Bear Stearns and Washington Mutual when they were at death's doorstep.

Dimon has also boasted of having built a "fortress balance sheet," in contrast to rivals such as Citigroup (C, Fortune 500) and Bank of America (BAC, Fortune 500) that have had to resort to federal assistance to shore up their capital. JPMorgan repaid its $25 billion TARP loan this month.

JPMorgan shares have gained 8% this year, and bulls such as BernsteinResearch analyst John McDonald, who rates the stock a buy, see more good times ahead.

"The market may not fully appreciate the extent to which JPM has spent the cycle not just 'surviving' -- but actually building, investing, and acquiring platforms for future growth," McDonald wrote in a note to clients this month. He said those gains should let the bank "emerge from the recession with greater earnings power and business momentum than it entered."

JPMorgan's momentum was especially apparent in Dealogic's rankings of debt underwriters. JPMorgan served as bookrunner, or lead arranger, on debt deals worth $185 billion in the first half. That's up from $172 billion last year.

By contrast, BofA Merrill's debt underwriting volume dropped to $140 billion from $243 billion a year earlier, according to the Dealogic report.

The weak underwriting performance comes after a tumultuous period at Charlotte, N.C.-based BofA. CEO Ken Lewis has come under fire for his decision to spend billions buying two struggling financial companies, Countrywide and Merrill Lynch, when their problems were getting worse.

Shareholders stripped Lewis of his chairman's title in April, though he remains CEO. He has also been questioned on Capitol Hill over the government's role in the Merrill deal. In January, the government provided BofA with $20 billion in capital and $118 billion in debt guarantees to ensure the bank would complete the purchase.