New York City Mayor Bill de Blasio picked up the endorsement of the Bronx and Queens borough presidents on Sunday as the Democratic primary election draws near.

Bronx Borough President Ruben Diaz Jr. and Queens Borough President Melinda Katz announced their endorsements in separate emails that were released as de Blasio spent the day campaigning with them in their respective boroughs. De Blasio addressed congregants at two Queens churches, greeted residents along a busy Forest Hills street, and spoke with parkgoers at the Orchard Beach basketball and handball courts in the Bronx.

“In the age of President Trump, the Bronx and all of New York needs a strong fighter for our most vulnerable communities,” Diaz Jr. wrote in a campaign email.

Diaz Jr., a close ally of Gov. Andrew M. Cuomo, who is often at odds with the mayor, had previously been among the names floated as possible primary challengers to take on de Blasio, but he never entered the race.

Katz wrote in an email sent by the de Blasio campaign: “At a time when our New York way of life is under attack, we need a Mayor who will stand for all New Yorkers.”

The endorsements come little more than two weeks before the Sept. 12 Democratic primary in which de Blasio, who is seeking his second term in office, faces a handful of long-shot opponents, including former City Councilman Sal Albanese; Mike Tolkin, chief executive of a virtual reality technology firm; and Richard Bashner, a Brooklyn attorney.

advertisement | advertise on newsday

Speaking to congregants at Evangel Temple in the Laurelton section of Queens, and Maranatha Baptist Church in Queens Village, de Blasio said he was not taking his re-election bid for granted and warned voters against sitting out the election.

“When you don’t vote, you can have unintended consequences,” de Blasio told congregants at Maranatha Baptist Church. “So take charge ... make your voice heard.”

De Blasio holds a commanding lead against his primary challengers — he has raised more than $4.8 million in campaign contributions since April 2014 compared with Albanese, his leading opponent in the pack of candidates, who has raised about $192,000 since December. A July 27 poll conducted by Baruch College and NY1 News found that among Democrats, 57 percent would vote for de Blasio, with 3.5 percent picking Albanese.

Despite the polling lead, de Blasio successfully argued to the city’s campaign finance board earlier this month that his campaign should receive an additional $1.6 million in public matching funds, saying the race was indeed competitive. The board was initially set to give the mayor $958,000 based on a formula for noncompetitive races.

Albanese, who spent Sunday campaigning at two Brooklyn street festivals, said in a telephone interview that he welcomed the mayor’s campaign blitz, hoping it would lead to “a full airing of the issues that matter to voters.”