NEW YORK — Bill de Blasio held a clear lead Tuesday night in New York City's mayoral Democratic primary as polls closed, according to interviews with voters as they left balloting places. It was unclear, though, whether he would top the 40 percent threshold needed to avoid a runoff.

Exit polls showed Bill Thompson, a former city comptroller, and City Council Speaker Christine Quinn competing for the other spot in a possible runoff while former U.S. Rep. Anthony Weiner's comeback campaign appears to have fallen short. The voter interviews were conducted by Edison Media Research for The Associated Press and other news organizations.

Actual voter returns were not yet available.

The exit polling showed the appeal of de Blasio, the city's elected public advocate, to be broad-based: He was ahead in all five boroughs; was ahead of Quinn, the lone woman in the race, with female voters; and ahead of Thompson, the only African-American candidate, with black voters.

But if no candidate surpasses 40 percent of the vote, the top two finishers advance to an Oct. 1 runoff.

The winner of that contest would face the Republican nominee in the Nov. 5 general election. Joe Lhota, ex-MTA chairman and former deputy mayor to Rudolph Giuliani, was battling billionaire grocery magnate John Catsimatidis for the GOP nominee. Exit polling was not available in that race.

In the closely watched race for New York City comptroller, exit interviews show Manhattan Borough President Stringer running ahead of ex-Gov. Eliot Spitzer, who was seeking a return to politics after resigning New York's governor's office in 2008 amid a prostitution scandal.

The winner of the mayor's race in November will assume the helm of the nation's largest city at a critical juncture, as it experiences shrinking crime rates yet widening income inequality, and as the nearly completed One World Trade Center building symbolizes a new era after the terrorist attacks of 2011.

Bloomberg, the businessman Republican-turned-independent, is completing his third term. While the city's registered Democrats outnumber Republicans 6 to 1, the GOP's recent success in mayoral elections has been largely attributed to a crime epidemic, the aftermath of the Sept. 11 attacks or other extraordinary circumstances.

De Blasio, 52, has fashioned himself as the cleanest break from the Bloomberg years, proposing a tax on the wealthy to fund universal pre-kindergarten and changes to city police practices he says discriminate against minorities.

"I'm a lefty and I've had enough of the righties," said Jessica Safran, a business consultant from the Boerum Hill section of Brooklyn who voted for de Blasio. "Even if de Blasio moves to the center if he gets elected, he'll be closer to the positions I want than the others."

De Blasio, who worked in Bill Clinton's White House and Hillary Rodham Clinton's Senate campaign before being elected to the city council and then public advocate, became the front-runner in the race's final weeks. His surge was as sudden as it was unexpected, in part thanks to and ad that centered on his interracial family, his headline-grabbing arrest while protesting the possible closure of a Brooklyn hospital and the defection of Weiner's former supporters in the wake of another sexting scandal.

"I liked what he said about the economic inequality in the city," said Norma Vavolizza, 65, who lives in the Bronx and works in marketing. "I think it's a serious issue that needs to be addressed.

Quinn, who was bidding to become the city's first female and first openly gay mayor, was the front-runner for much of the year, boasting the biggest campaign war chest and strong establishment backing. But she has been dogged by her support to change term limits to let Bloomberg run again in 2009, a decision unpopular with liberals who make up the bulk of Democratic primary voters.

Turnout appeared light, but the city's complaint line received several thousand voting-related calls. Many reported jams and breakdowns in the antiquated lever machines, which were hauled out of retirement to replace much-maligned electronic devices.

In some sites, the broken machines forced voters, including Lhota when he tried to vote at his Brooklyn polling place, to use pen and paper to cast their ballot.

The mayoral campaign was waged in hundreds of candidate forums and across millions of dollars of TV ads and was largely fought on the legacy of the Bloomberg era. Substantial policy differences were scarce among the Democrats, who agreed that the school system needed an overhaul, that the city's poor had been forgotten, and that stop-and-frisk police tactics used to stop suspicious people needed changing amid claims that police unfairly targeted blacks and Latinos.

Thompson nearly defeated the billionaire mayor four years ago. This year, he ran a quiet, centrist campaign with hopes of receiving enough support from minorities to reach the runoff.

Weiner surprisingly entered the race in May after being in political exile since resigning from Congress in 2011 upon admitting to lewd online exchanges with women who were not his wife.

His candidacy sparked curiosity and popular interest, and he immediately shot to the top of the polls. But support collapsed almost as quickly when he revealed in July that he continued the online behavior even after his resignation from federal office.

A fifth candidate, Comptroller John Liu, was bogged down by a fundraising scandal. While Liu was never charged with wrongdoing, two of his associates were convicted of participating in an illegal money-raising scheme, and Liu was denied city matching funds for his campaign.