Coal, like railroads, steel and other engines of the nation’s industrial expansion in the 19th and early 20th centuries, helped drive Wall Street’s profits for generations. More than a century later, the coal industry is in a free fall and the banks are pulling away.

“Given the state of the coal industry today, I think Mr. Morgan himself might make the same decision,” said Jean Strouse, a biographer of the banker.

Some banks say they are trying to do their part to curtail climate change by moving away from coal projects and financing ventures that produce less carbon. But bankers also say there is a more basic reason for the shift: Lending to coal companies is too risky and could ultimately prove unprofitable.

Coal companies are being squeezed by competition from less expensive energy sources like natural gas and by stiffer regulations — pressures that show no signs of letting up.

As a result, even the most secure loans — like those made to companies emerging from bankruptcy, known as debtor-in-possession loans — are increasingly off limits for many banks, according to bankers and industry lawyers.

And it is not just big banks. Even many more daring investors like hedge funds and private equity firms, which are usually eager to pounce on industries in distress, are shying away from coal because of deep uncertainty about its future.

It is a starkly different scene in the oil industry, where investors are raising hundreds of millions of dollars to snap up the debt and equity of troubled companies that are struggling with an oversupply of oil. Despite the immediate stress, many investors expect the oil glut will burn off by next year and prices will rebound.