Bank of America Corp. for years used its government-backed U.S. banking subsidiary to finance billions of dollars in controversial trades that helped hedge funds and other clients avoid taxes, according to internal documents and people familiar with the matter.

The bank last year quietly started phasing out the practice of using funds from its U.S. banking unit to finance transactions by its European investment-banking arm that, among other things, helped hedge funds avoid taxes on stock dividends, according to the documents...