BAGHDAD — Iraqis defied insurgents who lobbed hand grenades at voters and bombed a polling station Sunday in an attempt to intimidate those taking part in elections that will determine whether their country can overcome deep sectarian divides as U.S. forces prepare to leave.

The conclusion of the vote, however, did not spell an immediate end to political uncertainty. It could be days until results come in and with the fractured nature of Iraqi politics, it could take months to form a government.

Sunnis and Shiites seemed united in one way Sunday – defiance in the face of violence. Many came out of polling booths waving fingers dipped in purple ink in a now-iconic image synonymous with Iraq’s democracy. In Baghdad, relatives who had just lost a family member in a bombing walked down to the polling booth to vote.

The violence was a direct challenge to Prime Minister Nouri al-Maliki, who has gained popularity as violence across the country has plummeted.

“I voted for Nouri al-Maliki because I trust him as a man who succeeded in getting rid of militias and building a strong state,” said Saadi Mahdi, a 43-year old engineer in the southern city of Basra. It was there that al-Maliki first established himself as a leader willing to go against his fellow Shiites when he routed militias aligned with anti-American cleric Muqtada al-Sadr.

Insurgents used mostly rockets, mortars and explosive-filled plastic bottles hidden under trash to terrorize voters on their way to the polls. With those tactics, they managed to get around a vehicle ban in place across the capital for most of the day and killed 36 people, almost all of them in Baghdad.