"I'm just looking to keep the yellow jersey, not to win any more stages," Froome said. "Alberto's shown time and time again that he's a rider to be reckoned with. He's going to keep pushing me every day."
Froome was slower than Contador on the first part of the undulating 20-mile course, from Embrun to Chorges in the French Alps. But he made a crucial bike change midway through to gain time.
"The first and the second check, I know I was a little bit behind Alberto," Froome said. "That bike change really made the difference."
Froome, who has also won two mountain stages, made up for last week when he was edged out by Tony Martin in the first time-trial in Stage 11 even though he didn't expect to win this one.
"I went into today thinking: 'OK, I'm going to give this a really good shot,' but I'm not going to empty myself in respect of what's coming up (in the mountains,)" Froome said. "I'm over the moon with the result. I really expected to lose at least 30 seconds to a minute."
Bauke Mollema held second place overall for several stages, but Contador took his place with the Dutchman dropping to fourth.
Joaquin Rodriguez finished the stage in third place, 10 seconds behind Froome, who is 4:51 ahead of Contador's Saxo-Tinkoff teammate, Roman Kreuziger. Mollema is fourth, 6:23 back.
"I definitely get the feeling that the Spanish guys are racing absolutely full gas every day, and they're not going to slow down just because I have the advantage of four minutes," Froome said. "It's going to be a race all the way to Paris."
Froome, wearing an aerodynamic black helmet with a thick yellow stripe down the middle, coughed into his right hand as he prepared to start. When the 5-second countdown finished, he puffed his cheeks and rolled down the ramp.
The day after narrowly avoiding a crash when Contador fell in front of him on a long downhill, Froome started cautiously on a circuit. The road was slippery because of afternoon rain and featured two short, sharp climbs and two quick descents.
"The first downhill was dangerous and very technical, so I didn't want to take any risks," Froome said.
He was 2 seconds behind Contador at the first time split. It looked like Contador's day, with Froome 11 seconds behind when reaching the top of the second climb.
But Froome made up the deficit on his new bike.
"The first bike was more adapted to climbing," Froome said. "The second bike was a little faster."
Riders face mammoth climbs before the evening finish Sunday on the Champs-Elysee.
The 107-mile trek Thursday from Gap to L'Alpe d'Huez features two HC ascents of L'Alpe d'Huez one of the Tour's most famed climbs. Both of the ascents are known as HC (Hors Categorie, meaning they are so tough they are considered beyond classification.)
There's also a treacherously fast descent from the top of Col de Sarenne which makes Froome nervous after nearly falling on Tuesday.
"Safety definitely comes first. It's a dangerous descent as it is, so if it starts raining, I would hope that the race organizers take the decision to make it only one time up the Alpe d'Huez," and change the finish line are, Froome said. "Just in terms of the safety of the riders, I think that has to come first."
There are two more HC climbs and two Category 1 ascents on Friday, and an HC finish on Saturday.
The route Wednesday started with a 4-mile ascent and the first descent featured several hairpins.
French cyclist Jean-Christophe Peraud fractured his right shoulder training in the morning and landed on it again when he fell late on in the stage.
1. Chris Froome
2. Alberto Contador +4:34
3. Roman Kreuziger +4:51
4. Bauke Mollema +6:23
5. Nairo Quintana +6:58
Tour de France
O Stage 18 • Gap to Alpe-d'Huez
Thursday, 4 a.m.
TV • NBCSN