HSBC and Barclays on Monday reported a surge in bad debts to a combined $21 billion as recession took its toll on borrowers, but Britain's two biggest banks offered encouragement they could be through the worst.

Both banks reported buoyant investment bank earnings as they took advantage of resurgent debt and foreign exchange trading, and defended bumper payments to top bankers as public anger simmers against the prospect of million-dollar payouts again.

Barclays and HSBC , who unlike many rivals avoided taking taxpayer rescue funds, said having top talent helped them grab market share from troubled rivals to drive their investment banking growth and underpin earnings.

By 1445 GMT HSBC's shares were up 5.5 percent at 639 pence while Barclays was 8.2 percent higher at 327 pence. HSBC hit a seven-month high and Barclays shares hit their highest since October.

(The results) were certainly better on average than people were expecting, said David Bradbury, head of equities at Canada Life. HSBC, which is normally very cautious, doesn't seem as cautious as it normally does, which is a positive sign.

You can argue the worsening bad debts will be more of problem for HBOS/Lloyds , which is the obvious read-across.

HSBC <0005.HK>, Europe's biggest bank, reported a pretax profit of $5 billion for the six months to the end of June, halving from $10.2 billion a year earlier, but just ahead of an average forecast of $4.9 billion from 11 analysts polled by Reuters.

Barclays' profit came in at 3 billion pounds ($5.02 billion), up 8 percent from a year ago, but below the average forecast of 3.5 billion pounds from seven analysts polled by Reuters.

HSBC unveiled a 39 percent jump in bad debts to $13.9 billion, while Barclays' impairments soared 86 percent to 4.6 billion pounds.

Both banks remained cautious on economic prospects, but said there were glimmers of encouragement.

It's possible we may have passed, or are about to pass, the bottom of the cycle in the financial markets, but even then it's dangerous to assume there will be no further pain, HSBC Chief Executive Michael Geoghegan said at a press conference.

In particular, unemployment trends and global trade flows give us cause for concern, he said.

Bad debts are fueled by unemployment, currently at a 12-year high of 7.6 percent in the UK, and economists say the jobless rate is unlikely to reach a peak until after economic recovery has begun.

Barclays said it had seen signs of a slowdown in the rate of increase in impairments or even stabilization, but bad debts are likely to top 9 billion pounds for the full year, up from 5.4 billion in 2008.

SETTING THE TONE

The results from Barclays and HSBC continued the trend shown by U.S. rivals such as JP Morgan , where investment banking revenues have bounced back from the torrid end to 2008, but retail bad debts are soaring as the recession feeds into the wider economy.

Other European banks are expected to follow the same pattern, including BNP Paribas , Unicredit and Royal Bank of Scotland later this week.

HSBC and Barclays both reckon they are well positioned to take advantage of problems among rivals who were forced to sell stakes to governments to stave off collapse during the worst financial crisis since the 1930s.

Bonus payments for bankers are not set until the full year and the banks said they were assessing UK government proposals to require lenders to disclose all their top earners as a backlash to banking pay threatens to revive.

This is a hot topic and we have to be sensitive to what we see and hear in the world, John Varley, Barclays chief executive, said at a press conference.

But my job is to assemble the best team that I can. We have to go out and hire and retain the best people in the industry, and there's a market economy that determines whether you get the best or you don't get the best, he said.

The banks rebuilt balance sheet strength during the half year. HSBC said its core tier 1 capital ratio had risen to 8.8 percent by the end of June and Barclays' core tier 1 ratio is set to reach 8.8 percent from 5.6 percent at the end of December, once it completes the $13 billion sale of its asset management arm Barclays Global Investors to U.S. money manager BlackRock, which it said is on track for later this year.

Domestic rival Royal Bank of Scotland is set to clinch the sale of most of its Asian assets to Australia and New Zealand Banking Group later this week for about $775 million, a source familiar with the matter said.

(Additional reporting by Clara Ferreira-Marques and Victoria Bryan; Editing by David Cowell and Rupert Winchester)