DES MOINES — They were each on overnight patrols early Wednesday, a rookie police officer and a veteran a few miles apart in the Des Moines area, when officials say they had the lethal misfortune to cross paths with an armed, disturbed man whose life was unraveling. Each officer was gunned down in the driver’s seat of his patrol car, without so much as a chance to unholster his weapon.

Investigators quickly identified a suspect in the slayings, who then surrendered — a local man described as a troubled loner who was familiar to the police in his suburban town, Urbandale. He had a string of arrests and confrontations with officers and others, but nothing in his record approached the scale of violence that erupted here.

Just hours before the two officers were killed, a court had ordered the man, Scott M. Greene, 46, to move out of his mother’s house, after she accused him of emotional and physical abuse. A few weeks ago, the Urbandale police had escorted him out of a football game being played by his daughter’s high school, after he waved a Confederate flag in front of black students, leading to restrictions on his ability to set foot on school property.