Banks are lending to companies and individuals at the fastest pace since the financial crisis, helping propel profits to near-record levels.

U.S. banks posted $40.24 billion in net income during the second quarter, the industry's second-highest profit total in at least 23 years, according to data from research firm SNL Financial. The latest...