PHOENIX — President Obama hailed both this city’s and the country’s comeback from the housing bust on Tuesday, and said it was now time to reduce the federal role and risk in the mortgage market “to make sure the kind of crisis we went through never happens again.”

He proposed to “wind down” Fannie Mae and Freddie Mac, for the first time outlining his approach to overhauling the two giant mortgage-finance companies that were taken over by the government when they failed nearly five years ago. The companies, which Mr. Obama described in an appearance here as “not really government, but not really private sector,” recently began to repay taxpayers.

“For too long, these companies were allowed to make big profits buying mortgages, knowing that if their bets went bad, taxpayers would be left holding the bag,” the president said. “It was ‘heads we win, tails you lose.’ ”

Since early 2011, the administration has voiced support for overhauling Fannie Mae and Freddie Mac, which long benefited from an implicit government guarantee. Years ago the companies came to symbolize a self-dealing Washington culture beneficial to both parties, and especially Democrats, but Mr. Obama’s remarks on what comes next were his most specific. For several years, the administration held back from revamping the mortgage-finance system for fear of rattling a weakened market.