With all four teams still in with a chance of progressing, it was a topsy turvy night in Group F, but the City trio were left celebrating after Portugal drew 2-2 against France and Germany recorded the same result against Hungary.
It means Gundogan will meet four City team-mates in the next round, with Joachim Low’s men set to face England after Leon Goretzka’s late leveller prevented Hungary from progressing with a surprise victory.
City’s No.8 completed 58 minutes at the Allianz Arena, where the home side were twice forced to come from behind.
Kai Havertz’s close range header got them back in the game after Adam Szalai’s superb diving header had put the visitors in front, but it took just 90 seconds to restore their lead as Andras Schafer beat Manuel Neuer to a forward ball and headed home.
Goretzka, who replaced Gundogan, fired home from inside the area six minutes from time to prevent a shock exit for the Germans.
By then the scoring was complete at the Ferenc Puskas Stadium, where Bernardo and Dias both started for the defending champions.
The City midfielder impressed in the first half as Cristiano Ronaldo fired Portugal in front from the penalty spot after Hugo Lloris caught Danilo as he attempted to punch away a cross.
Karima Benzema equalised with a penalty of his own when Nelson Semedo tangled with Kylian Mbappe and the Real Madrid striker added a second with a cool finish immediately after half-time.
Ronaldo levelled on the hour mark, winning and converting a second penalty to equal the men’s all-time international goalscoring record and the point was enough for Portugal to qualify in third place.