NEW YORK, NY – AUGUST 16: Public Advocate and New York City Mayoral candidate Bill de Blasio speaks to voters at a subway station in Brooklyn on August 16, 2013 in New York City. In the latest polls, de Blasio is in a tie with fellow candidate Christine Quinn.

NEW YORK — Bill de Blasio has gone from afterthought to front-runner with stunning speed.

The most liberal candidate in the New York City mayoral race, whose City Hall bid was floundering mere weeks ago, now enjoys a shocking perch atop the polls in the latest turn of the most unpredictable citywide campaign in decades.

With the Democratic primary less than a month away, de Blasio might have hit his stride at the right time.

De Blasio, the city’s public advocate, has been given a second look by an electorate that appears intrigued by his progressive policies and charmed by his multiracial family. His first TV ad, narrated by his softspoken 15-year-old son, came out just before his rise in the polls.

De Blasio, of Brooklyn, also has benefited by the implosion of Anthony Weiner’s candidacy, winning over legions of supporters turned off by the former Brooklyn and Queens congressman’s latest sexting scandal.

“When Weiner entered the race, de Blasio was the most hurt, since they were both outer borough candidates appealing to the same progressive voters,” said Jeanne Zaino, a New York University political science professor. “Those people have now turned to him.”

Independent Mayor Michael Bloomberg’s impending departure after 12 years in office has created a wide-open race. The Democratic field alone has had three different leaders in as many weeks.

A Quinnipiac University poll this past week showed that de Blasio’s support had doubled in less than a month, pushing him from fourth to slightly ahead of the pack. A second poll released last week showed him in a dead heat with City Council Speaker Christine Quinn, with ex-Comptroller Bill Thompson slightly behind. Weiner, once the leader, is now fourth.

De Blasio, 52, said he thinks it was simply a matter of time before his message resonated with left-leaning voters in New York City, where Democrats outnumber Republicans 6-to-1.

“It’s happening now because people are finally starting to focus on the race,” de Blasio said. “After 12 years of Mayor Bloomberg, people want a real change.”

De Blasio has aggressively courted minority voters, who are expected to make up more than 50 percent of the electorate on primary day Sept. 10. He has won endorsements from several black and Latino elected officials and the city’s largest labor union, composed largely of minority workers.

As news of the deadly mass shooting at Marjory Stoneman Douglas High School in Parkland, Florida, unfolded last week, Pia Guerra, a 46-year-old Vancouver-based artist, felt helpless. She couldn’t bring herself to go to sleep, so she began to draw.

Police who find suspected drugs during a traffic stop or an arrest usually pause to perform a simple task: They place some of the material in a vial filled with liquid. If the liquid turns a certain color, it’s supposed to confirm the presence of cocaine, heroin or other narcotics.