A policeman in the Puerto Rican city of Ponce entered the office of his commanding officer, held her and two other members of the force hostage, and then fatally shot all three.
The shooter, identified as Guarionex Candelario Rivera, was arrested immediately afterward.
The incident took place Monday morning following an argument at work that temporarily shut down the station in the U.S. territory's second largest city, authorities said.
The suspect held a female lieutenant, a male commander and a policewoman hostage before he killed them, police spokeswoman Mayra Ayala told the Associated Press. She said authorities were about to start negotiations with the suspect when the victims were killed.
Police did not yet have information on a motive, Ayala said.
According to local media, El Nuevo Día and El Vocero de Puerto Rico, 50-year-old Candelario spent 19 years on the force but had been kept on restricted duties for long stretches because of “problematic behavior.” He worked in the anti-drug division.
Gov. Alejandro García Padilla told reporters that the suspect was injured during the shooting and remains hospitalized. García declined to say what kind of injuries the officer received and how they were inflicted.
"This is a very tragic situation that appalls us all especially because it occurred during the holidays," said police spokesman Axel Valencia.
Authorities evacuated the station to investigate threats of a possible explosive device in the suspect's car, but they did not say whether anything was found.
Police said at a press conference that the suspect previously had been stripped of his weapon but received a psychological evaluation nearly two years ago and his weapon was returned. Authorities declined to provide any other details, saying the investigation was barely starting.
"Ponce is in mourning," Mayor María Melendez said in a statement. "May God give the family members of the police officers involved the strength, fortitude and serenity to absorb this news."
Officials said the victims were 1st Lt. Luz Soto Segarra and Cmdr. Frank Román Rodríguez, both 49, and policewoman Rosario Hernández de Hoyo. Soto's husband also was a police lieutenant, said José Cruz Martínez, vice president of the Puerto Rican Police Union.
Soto and Román each had been with Puerto Rico's police department for more than 20 years, said Cruz, adding that they had been his friends for 15 years.
"They were both excellent people," Cruz said in a phone interview. "They were always supportive of their coworkers."
Cruz said he and his wife would occasionally go on motorcycle road trips with Soto and her husband, who lived in the nearby town of Yauco. He said Román was originally from the western town of Mayaguez.
"He rarely had any time off," Cruz said of Román.
Valencia said Román was named Commander of the Year for Ponce in 2014.
Based on reporting by the Associated Press.