Colombian rider Rubio (Movistar) delivered a perfectly-timed sprint to race past Cepeda (Education–EasyPost) and then Pinot (Groupama-FDJ) on the final climb at Crans Montana to snatch victory and earn his first Grand Tour stage win in style.
In a three-way duel on the slopes of Crans Montana, Pinot and Cepeda attacked in turns during a thrilling final ascent before Rubio dug deep and caught both of his fellow escapees with a late burst.
"It will take time for me to realise that I won a stage of the Giro d'Italia. I didn't believe I'd do it," said Rubio, who raised his arm above his head and pointed to the sky as he crossed the finish line.
"It's been difficult with the bad weather. But I had to keep going. I knew that Pinot was very strong, Cepeda as well. I had to finish with him and play it well tactically."
Rubio finished six seconds ahead of Pinot (Groupama–FDJ), with Cepeda (Education–EasyPost) another six seconds behind.
The race has been plagued by dreadful weather and organisers had already removed the climb up the Great St Bernard Pass from the 13th stage, shortening the 207-kilometre route to 199 kilometres due to snow and the risk of avalanches.
Riders made their scheduled departure under heavy rain at Borgofranco d'Ivrea but quickly re-boarded their team buses, before organisers re-routed the start of the stage to Le Chable, at the bottom of the Croix de Couer.
"Given the adverse weather conditions, especially on the Italian side, the Commission decided to meet the athletes' requests by applying the Extreme Weather Protocol," organisers said.
Stage six winner Mads Pedersen (27), who was second in the standings for the points jersey, dropped out of the race after falling ill overnight, becoming the latest rider to abandon this year's Giro.
"Mads had a troubled night with a cough. He woke up this morning with a sore throat and tracheitis and is not fit to race," his Trek-Segafredo team said earlier on Friday.
Saturday's stage 14 is a 193-kilometre ride from Sierre to Cassano Magnago.