Banks worldwide are in danger of losing significant profits in several lending areas to nonbank alternative lenders, according to a McKinsey study.

The global banking industry earned a record $1 trillion in profit last year and has seen stabilizing returns on equity, according to McKinsey's 2015 Global Banking Annual Review. But the industry has also shown signs of weakness; profit margins, for example, fell by 185 basis points last year.

More troubling is the prospect of nonbanks stealing market share from banks, by targeting an increasingly digital-savvy customer base. These customers can be lured away by an array of nonbank options, as financial-technology companies numbered more than 12,000 in August, McKinsey found.

They're also well-funded. Fintech companies raised $12.2 billion in venture capital investments in 2014, more than triple the venture capital raised in 2013.

Nonbank alternative lenders are poised to steal significant market share, McKinsey said. By 2025, banks could lose 60% of their profits in consumer finance, 34% in payments and small business lending, 30% in wealth management and 20% in mortgages.

There are some silver linings for banks, however. The McKinsey report notes that the business model of many financial-technology companies has not yet been tested by time, tighter regulations, a recession or higher interest rates. Any of those factors could weaken the pull of nonbanks.

Additionally, banks' market share of household credit has grown. But at the same time, marketplace lending might counteract this trend.

To maintain their competitive edge, McKinsey recommends that banks focus on corporate banking and other core services that are relatively shielded from a digital takeover. Banks should also diversify services by exploiting customer data and target customers at the local level.

"[B]anks must decide soon, probably within three years, or the choice will be made for them," the report warned.