A California public official who barreled down a highway asleep at the wheel was saved by quick-thinking cops — and possibly the Autopilot function of his pricey Tesla.

Alexander Samek, chair of the Los Altos Planning Commission, was doing 70 mph on Silicon Valley’s Highway 101 after drunkenly conking out in his electric-powered car around 3:30 a.m. Friday, police said.

When California state highway cops pulled up next to Samek, they noticed he’d dozed off and tried toget his attention, Officer Art Montiel told The Post.

But the 45-year-old was so zonked he continued speeding along for seven miles, they said.

Cops maneuvered their patrol car in front of Samek’s Tesla, tailed by another cop car to keep other drivers away.

Samek’s vehicle slowed and eventually stopped in a lane on the highway.

He was safe — and happily still snoozing away, according to Montiel, who noted the driver was “unresponsive.”

They pounded on the window to rouse him. He woke up and they took him to a gas station, where Samek failed a breathalyzer and was charged with drunken driving.

Video footage of his arrest shows Samek, who also works as a real estate developer, chuckling as officers interrogate him.

He appears bleary-eyed and smiling in his mugshot.

Local reporters caught a downcast Samek exiting the San Mateo County jail hours after his arrest in the same clothes he wore in the mugshot. He could not be reached for comment Saturday.