HMS Trent departed from Portsmouth Naval Base on Wednesday morning to head to the Mediterranean.
It is deploying on NATO's Operation Sea Guardian, the alliance's counter-terrorism mission in the region.
The ship deployed on the mission last year.
The location will enable the 90m-long (295ft) ship to work alongside north African partners in counter-piracy operations in the Gulf of Guinea.
Among HMS Trent's 65-strong crew heading for the Rock is Sub Lieutenant Ben Hoffmeister, who is following in the footsteps of his two grandfathers who fought on both sides in the bitter Battle of the Atlantic in the Second World War.
Ernest Hoffmeister served in the Atlantic and Arctic determined to keep the UK's sea lanes open, while Sub Lt Hoffmeister's maternal grandfather, Erwin Menzel, crewed a U-boat determined to strangle Britain's lifelines.
Sub Lt Hoffmeister said his grandfather Erwin was "instrumental in raising my interest to join the Navy".
"They got on incredibly well when they eventually met," he said.
"It seemed the shared experience of the Battle of the Atlantic was more important to them than which side of the war they had fought it on.
"That legacy is perhaps the most important aspect to take away from their story."
HMS Trent is the third of five new River Class Offshore Patrol Vessels and made her first operational deployment to Gibraltar in August last year after being commissioned into the fleet earlier that month.
The Clyde-built ship has a range of 5,000 miles, can remain at sea for 320 days of the year and is designed to conduct operations with Merlin helicopters.