The vessels are the Fulda minesweeper and the Mosel supply ship, which had been stationed in Djibouti to prepare for a possible international operation to clear mines from the Strait of Hormuz.
Following consultations within the German government, officials decided that the ships would sail toward the Suez Canal in the coming days alongside vessels from other countries.
The prospect of a mine-clearing operation has become less likely because of the renewed escalation between Washington and Tehran, the German Defense Ministry said.
Keeping the ships in the region no longer serves a clear purpose and would place unnecessary strain on their technical systems, the ministry added.
The return voyage through the Red Sea remains risky because of attacks by Yemen’s Houthi forces on civilian shipping. German vessels will therefore travel under the protection of warships equipped with air-defense systems.
Berlin is seriously concerned about the risk of further escalation following Houthi attacks on oil tankers, German Defense Minister Boris Pistorius said.
The Iran-backed Houthis said on July 23 that they had attacked Saudi tankers in the Red Sea.
NASA satellite imagery showed a fire aboard one of the vessels, CNN reported.
U.S. President Donald Trump later warned that Washington could use force if the Houthis again attacked ships in the Red Sea.