This is basically what happens (I think that another person's way of describing the events might facilitate the understanding):
OoT Link challenges Ganondorf after having freed the Seven Sages. At this point, Ganondorf has already kidnapped Zelda. Link fails in this battle (note that he might survive, though), allowing Ganondorf to take the Triforce of Courage from him. Ganondorf also takes the Triforce of Wisdom from Zelda.
However, all is not lost, since Zelda and the other Sages seal Ganondorf inside the Dark World, which came to be when Ganondorf originally touched the Triforce. (Note that this is probably a retcon since
AlttP clearly states that the Dark Word was created when Ganonodorf wished upon the Triforce, just before the Seal War).
Time passes and people try to find their way to the Dark World, in search for the Golden Power, however, no one returns. One day, evil started leaving the Dark World. In order to stop this, and in turn Ganon who lies behind the invasion, the King of Hyrule (whether it be the one from
OoT that did survive, since there is no information on his whereabouts, or a succeeding one), orders seven Sages, who might be the ones from
OoT or not, to seal the entrance to the Dark World. This is the Seal War
/Blue Window