The loss, which came at the semi-final stage of the World Cup that they are hosting, is the biggest ever suffered by the Brazilians at the tournament.
However, Pele, who is Brazil's leading ever goalscorer, believes that the five-time winners can recover in time for when the Russians hold the competition.
"I always said that football is a box of surprises. Nobody in this world expected this result," he tweeted. "We'll get the sixth title in Russia. Congratulations to Germany."
Brazil last won the World Cup back in 2002.