"That's Swiss timing," Cancellara said to reporters after the race. "Time is on my side."
The 37-year-old Armstrong, who is coming out of a four-year retirement, began the day in third place but gained ground on Cancellara as Armstrong's Astana team won Tuesday's team time trial.
Cancellara kept the yellow jersey for a fourth consecutive day. The Swiss rider's Saxo Bank team finished third in the stage, 40 seconds behind Astana.
Armstong's team needed to beat Saxo Bank by more than 40 seconds in order for the seven-time Tour winner to claim the yellow jersey.
Tuesday's stage was a 24-mile team time trial that started and finished in Montpellier, France. The Tour ends July 26 in Paris.