Movistar rider Costa soloed to victory in the undulating 168 km ride from Vaison-La-Romaine to Gap after a late but timely attack on the final climb of the day, the 9.5 km-long Col de Manse.
Costa, taking his second career stage win on the race, had been part of an earlier 26-man breakaway that went on to build a significant lead on the main peloton over the hilly terrain leading to Gap.
He quickly built a lead on four chasers who, despite their efforts, came over the summit with a 45-sec deficit on the Portuguese.
With 11.5 km of downhill remaining, Costa's efforts before the summit paid off and he went on to cross the finish line 42secs ahead of Christophe Riblon, Arnold Jeannesson, Jerome Coppel and German veteran Andreas Kloden.
Meantime Froome, and Spanish rival Contador, who had tested the Briton with several attacks on the way to the Manse summit, both escaped disaster after crashing on one of the tight corners on the descent.
Froome went off the road and had to put one foot on the ground to steady himself, while Contador came off his bike altogether.
With overall second-placed Bauke Mollema showing his class by slowing to allow Froome and Contador to catch up, they resumed racing and finished the stage together in a small group at just over 10 minutes behind Costa.
Team Sky leader Froome retained his 4min 14sec lead on Dutchman Mollema of Belkin with Saxo team leader Contador still in third place at 4:25.