As part of the carrier's sea trials, Royal Navy helicopters have been landing on its four-acre flight deck for the first time.
These will be followed by fixed wing F35 Lightning II trials later this year.
Defence Secretary Gavin Williamson said:
"As the Rock casts its shadow over the flight deck of our world-class aircraft carrier, Gibraltar rightfully marks HMS Queen Elizabeth's first overseas stop as she refuels and takes on supplies before continuing her sea trials.
"I'm sure our friends in Gibraltar will be proud to see our future flagship sail through British waters into their famous port."
Captain Jerry Kyd, the Commanding Officer of HMS Queen Elizabeth, said:
"Gibraltar is the perfect stop for HMS Queen Elizabeth as we conduct our flying trials in the waters off the Iberian Peninsula.
"I am personally very lucky to have visited the Rock many times in my naval career, but well over a quarter of my sailors have not yet experienced what, for the Royal Navy, is something of an iconic run ashore."
Built at a cost of £3.1bn, HMS Queen Elizabeth was launched last December.