A gunman opened fire Sunday and killed six people at a Sikh temple near Milwaukee before he was killed in an exchange of gunfire with one of the first officers to respond to the chaotic scene, authorities said.