As a candidate for mayor, Bill de Blasio sought to differentiate himself from Michael R. Bloomberg in every way possible, vowing to turn the page on what he cast as an autocratic billionaire’s 12-year reign.

But as Mr. de Blasio, a liberal Democrat, approaches the midpoint of his own term as mayor of New York City, he has executed an abrupt and deliberate shift in posture.

Over the last month, Mr. de Blasio has repeatedly hailed Mr. Bloomberg, a political independent, as a champion for the city, doing so in unsolicited and sometimes unexpected ways. He applauded Mr. Bloomberg for his “vision and for the energy” spent in expanding the No. 7 subway line; he credited him for a hard-fought victory in winning mayoral control of the public schools; and he even took to Twitter to defend him against the National Rifle Association.

The timing of Mr. de Blasio’s overtures is no accident: The mayor and his advisers have increasingly come to see the rift between Mr. de Blasio and Mr. Bloomberg as a damaging and unnecessary political liability — especially at a time when Mr. de Blasio’s clashes with Gov. Andrew M. Cuomo, a fellow Democrat, have hurt his ability to push through important pieces of his agenda.