The deaths took place on Saturday night before polling, according to police who know of 22 dead.
The ANP, which is based on ethnic Pashtuns, had called for a boycott of the vote, claiming that the MQM, whose support comes mainly from Urdu-speakers whose families came from India, would rig it.
“Soon after announcing its boycott of the by-election, ANP's terrorists began killing innocent citizens in a bid to sabotage the election process,” an MQM statement said.
Provincial health minister Mohammad Saghir said gunmen in several parts of Karachi attacked people belonging to rival ethnic and political groups to “ruin the peace of this city”.
About 40 people were wounded, he said.
In August, an MQM politician was killed by gunmen, sparking violence which killed 100 people in a week.
The MQM dominates Karachi and is a member of the coalition that rules surrounding Sindh province. It has declared that it is considering pulling out of the provincial government after the weekend’s violence