KABUL, Afghanistan — Braving an all-out Taliban threat and the fatigue of repeated flawed elections, Afghans on Saturday voted to choose a president for a country suffering through one of the most violent periods in its recent history.

At a time when there is fighting in nearly two dozen of the country’s 34 provinces on any given day, it was feared the election would be marred by widespread bloodshed. While there were dozens of smaller attacks on Saturday, the security forces appeared to have prevented any mass-casualty assaults.

Afghanistan’s Interior Ministry said about 68 attacks had been carried out on election targets, resulting in the deaths of three police officers and the wounding of 37 civilians and two army soldiers.

But tallies arrived at by The New York Times, from conversations with local officials across the country, determined that at least 30 security personnel and 10 civilians were killed on Saturday, and at least 40 security forces and 150 civilians wounded — much higher than the official reports, but in line with the average daily toll of the country’s long-running war, now in its 18th year.