Though Mr. de Blasio ran for mayor — and, later, president — on an unapologetically progressive platform, he has generally not endorsed progressive insurgents. He did not endorse Zephyr Teachout in 2014 or Cynthia Nixon in 2018 when they challenged Gov. Andrew M. Cuomo from the left. Nor did he endorse Tiffany Cabán in the Queens district attorney’s race last year, as Mr. Sanders and Senator Elizabeth Warren of Massachusetts both did.

Mr. de Blasio’s backing adds to Mr. Sanders’s list of endorsements, which includes numerous unions and grass-roots organizations as well as Representatives Alexandria Ocasio-Cortez of New York, Ilhan Omar of Minnesota and Rashida Tlaib of Michigan.

Mr. de Blasio was in the presidential race for only four months last year and never exceeded 1 percent in a debate-qualifying poll; even voters in New York did not support him. But in something of a twist, his predecessor as mayor, Michael R. Bloomberg, has reached double digits in recent national polls with a veritable tsunami of spending from his personal fortune.