DES MOINES, Iowa -- A white man with a history of racial provocations and confrontations with police ambushed and fatally shot two white officers Wednesday in separate attacks as they sat in their patrol cars, authorities said.Police took 46-year-old Scott Michael Greene into custody hours after the killings and less than three weeks after he argued with officers who removed him from a high school football game where he had unfurled a Confederate flag near black spectators.Greene flagged down an Iowa Department of Natural Resources employee in a rural area west of Des Moines, identified himself and asked that the employee call 911. Sheriff's deputies and state patrol officers took him into custody.He's suspected in the early morning slayings of 24-year-old Justin Martin, who had been with the force in the Des Moines suburb of Urbandale since 2015, and 38-year-old Sgt. Anthony Beminio, who joined the Des Moines department in 2005.Greene was taken to a hospital for treatment of unknown health issues and was to be questioned later at Des Moines police headquarters, Sgt. Paul Parizek said.Police responded to a report of shots fired shortly after 1 a.m. and found the Urbandale officer. Authorities from several agencies soon saturated the area. About 20 minutes later, they discovered the Des Moines officer, who had responded to the first shooting, Parizek said.The shootings happened less than 2 miles apart, and both took place along main streets that cut through residential areas.In the first shooting, investigators believe the gunman walked up to the officer's car and fired more than two dozen rounds."I wouldn't call it a confrontation," Urbandale Police Chief Ross McCarty said. "I don't think he may have even been aware that there was a gunman next to him."The shootings follow a spate of police killings in recent months, including ambushes of officers in Dallas and Baton Rouge, Louisiana. Five officers were killed July 7 in Dallas. Three more were killed later that month in Baton Rouge.Race was an issue in those cases and others involving unarmed black men killed by officers. Greene is white, as were the officers.Greene appeared to have issues with people of other races.In the confrontation at the Urbandale High School football game, which Greene videotaped and posted on social media, he appeared to be trying to antagonize African-American fans when he shook a Confederate flag in front of them during the national anthem, McCarty said.In the video, officers can be seen asking Greene to leave school property while he insists he was assaulted and his flag stolen. He demands officers file theft and assault charges, saying someone hit his head and grabbed the flag.In a back-and-forth with officers that lasts for nearly 11 minutes, officers said they could take a report but they cannot let Greene back inside the stadium because the school has banned him from the property. They also note they were returning his flag and ask if he purposely wanted to create a conflict by displaying it near African Americans."I was peacefully protesting," he responds. "That's my constitutional right."The video ends with Greene promising not to "set foot on" school property and officers saying they will take down his information.Ardis Gardner of Des Moines told The Associated Press he was at the Oct. 14 football game to watch his teenage son play.Gardner, 47, who is black, sat with a group of other friends and family members when Greene, who was dressed in Army fatigues, approached them within a few feet and waved the flag at them during the national anthem."I was angry," said Gardner, who typically sits during the national anthem and prays. "It was senior night, and the spotlight should have been on those senior players. This was calculated for him to do it at that moment."A week later, Gardner said, Greene followed him and a group of black parents into another football game with a dog that was wearing a gun holster and a Confederate flag vest. Greene sat nearby again.After the video was posted on YouTube, someone identifying himself as Scott Greene commented, "I was offended by the blacks sitting through our anthem. Thousands more whites fought and died for their freedom. However this is not about the Armed forces, they are cop haters."In other incidents, court records show Greene was jailed and charged with interfering with official acts after resisting Urbandale police officers who tried to pat him down for a weapon on April 10, 2014. An Urbandale officer described him as hostile and combative. He entered a guilty plea and was fined.Two days later, Urbandale police were called to answer a complaint of harassment at the apartment complex where Greene lived. The complaint said he threatened to kill another man during a confrontation in the parking lot and yelled a racial slur used against blacks. Greene was charged with harassment.He pleaded guilty and received a suspended jail sentence and a year of probation. An officer wrote that Greene had complied with the terms of his probation, noting that he had obtained a mental health evaluation and "reports to have complied with the medication recommendations." The officer did not elaborate.Soon after the football game incident, on Oct. 17, a criminal complaint indicates Greene was involved in an altercation with his 66-year-old mother. Greene accused her of scratching and hitting his face. He captured the fight on cellphone video, which he used as evidence of the assault. A judge ordered Greene's mother to stay away from her son, and she was released on $1,000 cash bond.The Urbandale police chief said Greene was well-known to officers.Most officers in the city "have some understanding of Mr. Greene," McCarty said. "They've taken trips to his house, delivered service to him - never anything to this extent."It was unclear if either of the shootings was captured on police cameras.Greene has a daughter who attends Urbandale High School. The Urbandale shooting occurred near the school, and the city's entire school district closed for the day.The attacks on police this summer in Dallas and Baton Rouge came in the wake of several high-profile police shootings of black men, fueling a national debate about police use of force, especially against minorities. It has been a frequent topic in the nation's presidential race.Republican nominee Donald Trump has argued that police need the freedom to use greater force. Democrat Hillary Clinton has supported officers while calling attention to what she and others have called examples of bias in policing.Parizek said the officers' deaths are a blow to the city."They are our friends and co-workers," he said. "Des Moines is not a big city. We all know each other. We're heart-broken."