Mayor Bill de Blasio will fly to Iowa this weekend to campaign for Hillary Clinton, a fellow Democrat and his former boss, in the final days of her close race against Senator Bernie Sanders in the state’s presidential caucuses.

Mr. de Blasio is not widely known in Iowa, and his monthslong hesitation to endorse Mrs. Clinton last year caused consternation among her supporters.

But the left-leaning New York City mayor may now be a potent surrogate, bolstering Mrs. Clinton’s bona fides among liberals as she tries to head off Mr. Sanders, who represents Vermont and identifies himself as a Democratic socialist.

The Iowa trip, details of which were still being made final on Wednesday, comes after numerous talks between Mr. de Blasio’s advisers and members of Mrs. Clinton’s campaign staff. The message from Mr. de Blasio, according to several people who requested anonymity to describe private discussions, has been clear: How can I help?