Djokovic sealed his spot in the next round after a testing three sets on the controversial blue clay as he denied his doughty opponent on the Manolo Santana show court.
The top seed won the opening set with relative ease, but saw the scoreline reversed in the second as Gimeno-Traver raised his intensity and played with real confidence to level up the match before losing the decider.
In the only other second-round match to be played on Tuesday, sixth seed Tomas Berdych beat Kevin Anderson of South Africa 6-4 6-3.
The Czech will next face the winner of the second-round clash between Gael Monfils and Igor Andreev.
While Djokovic received a bye through to the second round, Gimeno-Traver - who had only won one ATP tour match this year prior to the tournament - had to overcome fellow qualifier Victor Hanescu of Romania 7-6 4-6 6-3 in his opening match, and it was a gruelling start for the Spaniard.
Djokovic held to love to get the match underway, before taking his opponent to deuce next game and providing an arduous test for the qualifier, who eventually held serve to establish himself in the opening set.
But Gimeno-Traver could not repel a barrage of pressure from his opponent in the fourth game of the match as Djokovic ruthlessly broke serve with a flurry of crushing groundstrokes.
The top seed consolidated his advantage and promptly cruised through the opening set without any real problems as every lengthy exchange occurred on the Spaniard’s serve.
But a rejuvenated Gimeno-Traver suddenly stamped his authority on proceedings with a stunning break of serve in the third game of the second set as Djokovic was punished for a touch of complacency.
The disgruntled Serb failed to find three first serves as his opponent clinically broke serve, with the Madrid crowd fervent in their support of the underdog, who looked suddenly buoyed by his resurgence.
It proved to be no fluke; Gimeno-Traver broke for a second time in successive Djokovic service games as he unleashed a torrent of blistering groundstrokes to establish a comfortable lead.
Indeed, Djokovic had no response as his opponent slammed an emphatic forehand down the line to hold serve and close out the second set to take it 6-2, and suddenly the Spaniard was back on terms in the match and brimming with confidence.
The world number one showed his displeasure with the blue clay surface and prompted whistles and boos from the Madrid crowd as he frequently remonstrated with the umpire during the course of the final set.
The final set was fiercely contested and finely poised until Gimeno-Traver finally caved into incessant pressure from the Serb, who broke serve after a seemingly interminable deuce to open up a 4-2 lead.
Gimeno-Traver forced his opponent to serve out for the match in typically determined fashion, but he could not stage a further resistance as the top seed secured his place in the next round.
Djokovic will next take on either Stanislas Wawrinka or Jurgen Melzer – who overcame 13th seed Feliciano Lopez - in the third round.