NEW YORK, April 14 (Reuters) - After having to stomach $31 billion worth of bitter mortgage settlements with government agencies a few years ago, JPMorgan Chase & Co swore off a huge swath of the home loan market.

Gone were borrowers with anything much less than pristine credit ratings. The cost of managing delinquent accounts and the threat of huge legal penalties were written off as not worth the risk. Better instead to focus on wealthier customers who wanted jumbo-sized loans that are beyond the reach of government housing finance agencies.

But there was a problem: Chase was leaving behind many of its mass market customers who were going to competitors for the conventional and government-guaranteed loans they wanted.

Now, the bank’s management team, led by Chief Executive Jamie Dimon, is working fiercely to change course – hoping to not only bring back customers, but influence what could be a reshaping of U.S. mortgage finance policy for the first time in a generation.

Customers will soon start seeing signs of this effort. Next month, Chase plans to launch advertising featuring Drew and Jonathan Scott, stars of the popular reality “Property Brothers” shows. In addition to TV spots, the campaign will feature cardboard cutouts of the telegenic twins in Chase branches.

Chase is also in the process of boosting its mortgage lending force by 10 percent, upgrading its loan-making software and jazzing up its smartphone app with more mortgage account tools.

At the moment, fewer than one in 10 Chase customers with home loans got them directly from Chase, a situation consumer banking chief Gordon Smith recently described as “terrible.”

“It is time to go after the opportunity we have with our own customers,” Mike Weinbach, the bank’s mortgage chief, said in a recent interview with Reuters.

JPMorgan Chase is not the only major bank that is restless after having stepped back from the U.S. mortgage market in the aftermath of the housing crisis last decade. At Bank of America Corp, executives say they are no more content with fewer than two in 10 of their customers with mortgage loans having borrowed from their bank.

Mortgage companies such as Quicken, Caliber and loanDepot.com scooped up much of the business from battered banks. (tmsnrt.rs/2orqDzB)

JPMorgan’s $31 billion cost of 13 mortgage-related legal settlements was second only to Bank of America’s $71 billion, according to data collected by bank analysts at Keefe, Bruyette & Woods.

Still, JPMorgan’s mortgage retreat stands out because the bank has used its scale and financial strength to gobble up market share in many other businesses, from credit cards and deposit-taking to commercial lending and Wall Street banking.

In backing away, JPMorgan saw its market share of conventional mortgages that are small enough to be resold to government-sponsored enterprises (GSEs) Fannie Mae and Freddie Mac fall by half, according to data from Inside Mortgage Finance.

Its share of all mortgage loans made directly by lenders fell to 2.8 percent last year from 12.6 percent in 2011. Logically, it should be close to Chase’s 8.3 percent of share of retail deposits, said Guy Cecala, CEO of Inside Mortgage Finance.

JUMBO MISSES

Chase opted to go after better-off borrowers who took out so-called jumbo loans in excess of the Fannie and Freddie limit, which then was $417,000 in most parts of the United States. Last year, jumbos were 49 percent of all loans Chase made, up from 14 percent in 2013. But jumbos account for only 18 percent of U.S. mortgages. By turning from bigger parts of the market, JPMorgan was hurting its wider consumer franchise.

That could be costly if it persists. Customers without Chase mortgages are twice as likely to leave as those who have them from the bank, Weinbach said. And, checking and savings account customers who get their home loans from Chase tend to add to their deposits.

Management’s effort to swing back may already be bearing some fruit. JPMorgan said on Thursday that it made $9 billion of home loans directly to customers in the first quarter, 3 percent more than in the same period a year earlier.

Chase’s shift comes amid crosscurrents in the mortgage market. The latest wave of loans for refinancing is abating as interest rates rise. That has reduced revenue across the industry.

But bank executives also see other conditions improving. Federal housing agencies have been loosening policies to help middle America get access to more credit. The millennial generation has also begun reaching the nesting age, leading to a new crop of home buyers.

The GSEs have already adjusted some rules to be less financially threatening to lenders. For instance, they dropped a demand that banks take back loans that default after three years unless there has been fraud.

Dimon sees a chance to get more relief from the government. This month he used four pages of his annual letter to shareholders to outline more changes he wants to see. He expressed particular concern about a bank’s costs and liability when loans it underwrites default.

Current rules have made lenders so cautious that they have not funded an additional $300 billion to $500 billion of loans for home purchases in each of the last five years, JPMorgan analysts estimate. The cost to the economy, they believe, has been one third of a percentage point of annual growth.

“If that number is right, shame on us,” Dimon told reporters on the bank’s post-earnings conference call on Thursday. “We should have done something about that. And, it can be done very quickly.”