A gunman killed six people on Tuesday after opening fire at close range in a hospital waiting room in the eastern Czech city of Ostrava, and a man who was believed to be responsible for the relatively rare instance of gun violence in the country killed himself hours later as the police closed in, the authorities said.

The police said on Twitter that several hours after the shooting at University Hospital in Ostrava, a 42-year-old man who had been driving a silver-gray Renault Laguna shot himself in the head after officers fired at his vehicle.

The shooting was the deadliest in the country since 2015, when a gunman killed eight people at a restaurant in Uhersky Brod, about 180 miles southeast of Prague.

Prime Minister Andrej Babis called the attack in Ostrava, near the border with Poland, a “great tragedy,” though much remained unclear, including the identity of the gunman and his motive.