The 43-year-old was forced into his first club minutes of the season after Alexander Schwolow was sent off on the stroke of half-time.
Derek McInnes' men already led through Claudio Braga's 27th-minute strike.
But the visitors were forced to cling on in the second period and needed a miraculous save from Gordon deep into stoppage time to claw away Emile Acquah's downward header.
Victory restores a six-point lead at the top of the Scottish Premiership for Hearts over both Celtic and Rangers, who travel to Aberdeen later on Sunday.
Gordon had played twice for Scotland in October to help his country qualify for a first World Cup since 1998.
However, he had not featured for Hearts since May due to a shoulder injury and then losing his place to Schwolow.
Dundee were seeking a fourth consecutive top-flight win for the first time since 1999 and had already taken points off Celtic and Rangers this season.
The home side were furious that the only goal was allowed to stand after Cammy Devlin took a free-kick from the wrong spot before the ball fell to Braga to drill in his 11th goal of the season.
Schwolow saw red for wiping out Tony Yogane on the edge of the box after a VAR review showed the Dundee player was not offside before the foul was committed.
But Hearts held out despite their numerical disadvantage to move one step closer towards ending the Old Firm's 40-year stranglehold on Scottish football.
