Armstrong, seeking his fourth straight tour title, found himself the subject of questions after failing to win the first individual time trial on Monday. There was speculation he might be vulnerable in the mountains this year, but those doubts ended on the second of the day's two climbs.
Armstrong, Heras and Spaniard Joseba Beloki left the rest of the pack behind on the final 13-kilometer climb to the finish line, catching and passing France's Laurent Jalabert.
Jalabert, who started the day three minutes off the overall lead, attempted an individual breakaway and at one point had more than a three-minute lead on Armstrong.
But that advantage disappeared under the withering assault of the world's most famous cyclist. Jalabert eventually finished ninth in the stage, 1:49 off the pace.
Armstrong covered the 158 kilometers from Pau to La Mongie in four hour, 21 minutes 57 seconds. Beloki finished seven seconds behind and Heras trailed by 13 seconds.
Igor Gonzalez Galdeano, who had held the overall lead for more than a week and who began the day 26 seconds in front of Armstrong, tried to keep up as the front runners began to pull away on the final climb. But he dropped back to finish 11th, 1:54 behind.
Beloki moved into second place overall, 1:12 behind Armstrong. Galdeano is third, 1:48 back, followed by Raimondas Rumsas of Lithuania (3:32) and Santiago Botero of Colombia (4:13).
Armstrong will wear the yellow jersey that goes to the race leader for the 37th time in his career Friday when the riders travel 199 kilometers from Lannemezan to Plateau de Beille. That trip will include five climbs, the last one being of about the same distance and grade as the one Armstrong used to his advantage Thursday.
Armstrong's stage win would likely have not been possible without the help of Heras, his United States Postal Service teammate who took his turn leading the charge up the mountain. Beloki, a member of the ONCE team, did little of the work while following Armstrong and Heras.
"Today Roberto Heras was the stage winner," Armstrong said. "He set a very, very rapid pace."
Armstrong indicated he would have let Heras cross the line first if he had not been worried abuot putting as much time between himself and Beloki as possible.
"We thought about that and we talked about it," Armstrong said. "The trouble is the time bonuses. When you've got an opponent like Beloki, you can't afford to lose any time. Not even eight seconds."