Robin Kelly, a Democrat who wants to ban assault weapons, has effectively become Jesse Jackson Jr's replacement in Congress for the Illinois second district after winning a primary for the party's nomination – all but ensuring she will win the 9 April special election in what is a heavily Democratic district.

Kelly, a former member of the Illinois state legislature, was backed by the New York mayor, Michael Bloomberg, in a campaign dominated by a gun control debate that is burning strongly after the Connecticut elementary school massacre.

In the Democratic primary race Kelly emerged early as a leader on gun control issues, a central theme during the race that helped her win support from Independence US, Bloomberg's super political action committee (super-Pac). It poured more than $2m into the race by airing anti-gun ads supporting Kelly, who favours an assault weapons ban and other gun measures proposed by President Barack Obama.

The ads targeted another frontrunner, Debbie Halvorson, a former congresswoman who is against banning assault weapons. The result was a setback for the National Rifle Association, which backed Halvorson and campaigned against Kelly.

"We worked really really hard," Kelly, a former state representative from Matteson, a south Chicago suburb, told the Associated Press. "We were on the right side of the issue and our message resonated."

She defended the financial support from Bloomberg, saying: "No one complains when the NRA was spending big money." In her victory speech Kelly vowed to fight for gun control until "gun violence is no longer a nightly feature on the evening news".

Halvorson conceded on Tuesday evening, saying the outside money played a roll. "It shows, unfortunately, you can't go up against that big money ... That's the problem with super-Pacs," Halvorson, who unsuccessfully challenged Jackson in a primary last year, told the AP. "There is nothing I could have done differently."

Bloomberg has been leading an anti-gun campaign backed by Mayors Against Illegal Guns, a coalition he started that now has the support of more than 800 mayors from around the US.

Bloomberg called Kelly's win an important victory for "commonsense leadership" on gun violence, saying in a statement that voters nationwide were demanding change from their leaders. His Pac, launched weeks before the November election, has spent more than $12m nationwide backing candidates who support gun control measures.

The primary race among four less well-known Republican candidates was too close to call.

Jesse Jackson Jr resigned in November after months of medical leave for treatment of bipolar disorder and other issues, then pleaded guilty this month to misspending $750,000 in campaign funds on personal items including a Rolex watch and fur coats.

Jackson's exit created a rare opening in a district where he was first elected in 1995. The primary featured 14 Democrats, including Mel Reynolds, who held the seat in the 1990s but served time in prison after being convicted of fraud and having sex with an underage campaign volunteer.