An off-duty Jacksonville sheriff's detective was taking his son to school when he was shot and critically wounded by a 19-year-old man who told his girlfriend minutes earlier that it was "going to be his last day on Earth," police said Wednesday.

The plainclothes narcotics detective chose to stop Kevin Rojas' white Cadillac after seeing it driving erratically, Jacksonville Sheriff's Office Chief Tom Hackney said. Rojas had just threatened his girlfriend with a gun and fired shots in their house before taking off in his car.

"It was bad luck that the officer encounters him immediately after this," he said.

The detective, who is not being identified because he works undercover, was wearing a "body armor" style vest when he stopped Rojas' car, Hackney said. He was taking his son to school, then continuing on to work. The word "police" was marked clearly on the vest.

Rojas immediately opened fire, Hackney said, hitting the detective in the head, upper body and hand. Thedetective was in critical but stable condition and alert at a hospital.

The detective returned fire, but missed.

Rojas ran away from the shooting scene and stole a large flatbed truck from a nearby business, Hackney said.

The detective, whose 14-year-old son was in the car but unharmed, managed to call for help.

With the help of a bystander, officers located the truck and pursued it into a nearby neighborhood, where it crashed into a house. Rojas ran through the house to the back, and two officers found him holding a gun. They ordered him to drop it, Hackney said, and when he didn't, Rojas was shot four times. He survived and is still in the hospital.

The officers who fired the shots that struck Rojas are on administrative leave.

The gun used by Rojas was legally purchased by one of his roommates, who told police she bought it because of his erratic behavior in recent weeks, Hackney said. Police said he had a minor previous arrest record.

Rojas' mother Amy Wyss told detectives and WJXT-TV that her son was not a violent man.

"This is not him," she said in a television interview. "I'm sorry the officer was shot. From the bottom of my heart, I'm sorry.