New York City Mayor Bill de Blasio endorsed Hillary Clinton for president Friday morning during a television appearance, ending a months-long process that had frustrated many close to him and Mrs. Clinton.

Mr. de Blasio made the endorsement on the MSNBC program “Morning Joe.”

He said he was “enthusiastically” endorsing Mrs. Clinton because “we have to take on income inequality as the issue of our time.”

Some people close to the mayor had pushed him to endorse Mrs. Clinton for months, as other powerful Democrats backed her. But he had resisted, saying he wanted to hear her vision and hold a forum for 2016 candidates in Iowa. He had repeatedly rebuffed questions about endorsing her.

Meanwhile, he met with Vermont Sen. Bernie Sanders in New York and praised him.