An Uber driver, who once claimed the devil controlled him through the ride-hailing app, pleaded guilty Monday to killing six people in a murderous rampage on the eve of his trial.

In a surprise move, Jason Dalton admitted to shooting eight people, two of whom survived, between fares in the Kalamazoo, Mich., area in February 2016.

The 48-year-old driver was in court on the final day of jury selection for his upcoming trial, when he unexpectedly confessed.

“I’ve wanted to do this for quite a while,” Dalton told Kalamazoo County Circuit Court Judge Alexander Lipsey. He then pleaded guilty to six counts of murder and two counts of attempted murder, and now faces life in prison without the possibility of parole.

On Feb. 20, 2016, Dalton gunned down unsuspecting victims at three spots around the city — including a restaurant and a car dealership — in between picking up customers for rides.

After the shooting spree, Dalton told cops the Uber app had turned him into Satan’s “puppet” and chosen his victims for him, according to police. He claimed a “devil figure” had made him do it by sending him messages though the app.

A few months later, Dalton went berserk in a Kalamazoo courtroom — ranting inexplicably about “black bags” — and was dragged off by officers as a witness burst into tears.

But a judge ruled that Dalton was fit to stand trial on 16 felony charges. He later dropped an insanity defense, according to MLive.com.

His lawyer, Eusebio Solis, said Monday he advised his client to plead not guilty.

But Dalton nevertheless confessed to the crimes, which also included weapons charges, to protect his family and victims’ families from the emotional trauma of a highly publicized trial, Solis said.

During the massacre, Dalton first shot 25-year-old mother Tiana Carruthers as she shielded a group of children near her home — but she survived.

He went on to kill 17-year-old Tyler Smith and his father Rich Smith, 53, who were shopping for cars at a nearby dealership.

Later, he opened fire in the parking lot of a Cracker Barrel, gunning down Mary Lou Nye, 62; Barbara Hawthorne, 68; Mary Jo Nye, 60; and Dorothy Brown, 74.

Abigail Kopf, 14, was shot in the head but survived, surprising doctors who feared she was brain-dead.

A month after the shooting spree, Dalton filed a handwritten lawsuit suing Uber for $10 million over a “hostile workplace environment.”

“I am currently in prison because of Uber,” Dalton whined in the complaint, griping that he never got a Christmas bonus and was not invited to corporate parties.