Dutchman Tom Dumoulin won the 38.4-kilometre stage against the clock in Berne but Spilak overhauled Britain's Geraint Thomas and Thibaut Pinot of France to win by just five seconds overall.
Katusha's Spilak, 28, came second on the stage, 18 seconds behind Giant-Alpecin's Dumoulin, with timetrial great Fabian Cancellara having to settle for third at 19 seconds in his home race.
Thomas took fifth on the stage but 18sec behind Spilak having begun the day just 13sec ahead of the rider from Slovenia.
Those two were expected to battle for overall victory with Pinot, who started the day in yellow, but the Frenchman was one minute and 50 seconds slower than Dumoulin on the stage and slipped to fourth overall, one place behind the Dutchman.
For Spilak, a one-week race specialist, it was his second victory in Switzerland having also won the Tour de Romandie in 2010.
He finished second at Romandie in the last three years and was also third at Paris-Nice earlier this year but he has never managed to turn his stage-racing form into into a challenge at one of the three-week Grand Tours.