Updated

Militants in Iraq unleashed attacks against polling stations as soldiers and security forces cast ballots two days ahead of parliamentary selections, killing at least 21 people on Monday, officials said.

The wave of attacks was an apparent attempt to derail the balloting process and to discourage the rest of the country's 22 million registered voters from going to polls on Wednesday in the first nationwide elections since the 2011 withdrawal of U.S. forces.

The early balloting for police and soldiers is meant to free up the 1 million-strong military and security forces for Wednesday, so they can protect polling stations and voters.

More than 9,000 candidates are vying for 328 seats in parliament, which is widely expected to be won by an alliance led by Shiite Prime Minister Nouri al-Maliki, who is likely to seek a third four-year term in office.

Security has been tight amid concerns that Sunni militants blamed for a recent resurgence of sectarian violence could target polling stations.

At one central Baghdad polling station, policemen went through four ID checks and search stations before they could enter the building on Monday. Inside, police dogs were used to search for explosives. Some policemen came to cast votes dressed in civilian clothes, to attract less attention.

But despite tight security measures, militants managed to strike polling centers in different areas.

One of the deadliest attacks took place in the town of Tuz Khormato, about 130 miles north of Baghdad, where a suicide bomber of foot blew himself up at a checkpoint leading to a polling center, killing six security personnel and wounding four, according to Maj. Gen. Torhan Abdul-Rahman Youssef said.

Youssef added that another suicide bomber hit a checkpoint leading to a polling center in the nearby city of Kirkuk, killing six policemen and wounding seven. He added that a civilian was killed and another wounded when a bomb went off in a street nearby, also in Kirkuk.

Interior Ministry spokesman Saad Maan Ibrahim said another bomber struck a polling center in Baghdad's western Mansour area, killing three troops and wounding four.

Another suicide bomber set off his explosive belt among a group of soldiers gathering at a checkpoint near a voting center in Baghdad's northern Azamiyah neighborhood, killing four soldiers and wounding 13, police and medical officials said.

In the town of Habbaniyah, 50 miles west of Baghdad, a  bomb went off next to a group of security forces as they were leaving a balloting center, killing a soldier and wounding five policemen, a policeman said.

And in the northern city of Mosul, two suicide bombers on foot tried to attack a polling center, a police officer said. The guards shot and killed one attacker as the second blew himself up outside the center in the southern Zeindan area, wounding five security personnel.

In another area, a bomb targeted a security convoy and wounded three accompanying journalists. All officers and officials spoke on condition of anonymity as they were not authorized to talk to the media.

"These are crucial elections that we hope will make things better in Iraq," said one voter, policeman Hatef Yidam. "We want peace and a life with dignity."

Hospital patients, medical staff and detainees were also voting on Monday. Abroad, Iraqi expatriates in more than 20 countries will also be able to cast ballots for a second day.

Iraq is experiencing a surge in sectarian violence, with Sunni militants increasingly targeting security forces, army troops and members of the nation's Shiite majority. The resurgence of the bloodletting, which nearly tore Iraq apart in 2006 and 2007, underscores the precarious politics of a democratic, but splintered nation.

It also mirrors the three-year-old conflict in neighboring Syria, where the civil war pits forces loyal to President Bashar Assad whose powerbase stems from followers of a Shiite offshoot sect, against mostly Sunni Arab rebels whose ranks are dominated by Islamists and militants from Al Qaeda-inspired or linked groups. Iraqi Shiite militiamen fight on the side of Assad's forces.

The biggest election-related violence in Iraq came on Friday, when a series of bombings targeted an election rally for a militant Shiite group, killing at least 33 people. The rally for the Iranian-backed Asaib Ahl al-Haq was held at a sports stadium in eastern Baghdad to present the group's parliamentary candidates.

An Al Qaeda breakaway group, the Islamic State in Iraq and the Levant, claimed responsibility for the attack, which triggered a wave of revenge killings late on Friday and Saturday. On Sunday, 10 people were killed in Baghdad's Shiite Sadr City district when a bomb went off at an outdoor market. No one claimed responsibility for the attack, which bore the hallmarks of militant Sunni groups.

Voters in Wednesday's polls are widely expected to cast ballots along sectarian and ethnic lines.

But balloting will not take place in parts of the vast and mostly Sunni Anbar province west of Baghdad, where Al Qaeda spin-off militants control parts of two cities, including the provincial capital, Ramadi.

Al-Maliki's government has meanwhile announced a weeklong national holiday to coincide with the elections, extending a previously announced three-day break. Such moves were common in past elections, chiefly to empty the streets and allow security forces faster access to attack sites.

A ban on vehicles will take effect on Tuesday night in Baghdad and stay in force throughout election day on Wednesday, a precautionary measure used in past voting to guard against car bombings.