Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A police sergeant in Birmingham, Alabama, was shot and killed and another officer was critically wounded in a shooting outside a nightclub early Sunday.

A suspect was in custody and a second, who was struck by gunfire during the shooting, was being treated at the hospital, police said.

Sgt. Wytasha Carter was killed during a burglary investigation in Birmingham, Alabama, on Sunday. Birmingham Police Department

The shooting happened just before 2 a.m. (3 a.m. ET) near downtown Birmingham. An undercover officer was investigating a rash of car break-ins when the officer spotted at least two people who appeared to be burglarizing a vehicle, police said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The officer called for backup, and the sergeant arrived, Police Chief Patrick Smith told reporters Sunday morning.

The officers approachedthe suspects when one suspect took out a gun and began to fire at them, Smith said.

"What I can tell you is it appears our officers were unable to respond,'' he said. “They were taken completely by surprise.”

Both officers and one suspect were taken to the hospital for treatment, Smith said, and a second suspect was arrested. Police said both suspects were about 18 years old and were believed to be from the Birmingham area.

The slain officer was identified as Sgt. Wytasha Carter, 44, of Birmingham. Carter had been a member of the Birmingham Police Department since 2011 and was promoted to sergeant last February.

The second officer, whose identity hasn't been disclosed, remained in critical condition Sunday night at University of Alabama-Birmingham Hospital, police said.

I offer my deepest sympathies & prayers as we mourn the death of Sgt. Carter, which came far too soon. Terrible loss for his loved ones, fellow law enforcement officers & our entire state. I am praying for the second officer still fighting to stay alive. https://t.co/BmvGiM9S4H — Governor Kay Ivey (@GovernorKayIvey) January 13, 2019

Carter, an Air Force veteran who is survived by his wife and children, is the first Birmingham officer to have been killed in the line of duty in more than 14 years.

"He was just driven," his supervisor, Lt. Shelia Finney, said in a statement. "He was a great sergeant. I enjoyed working with him."

Smith said: "This is one of the roughest hours of your career. There's not a chief, not an officer that ever wants to have to deal with this. This is a very difficult thing for the family, very difficult for the department."