I believe that Link was inside of the Windfish's dream while dreaming his own. I think their minds were connected through a dream.
Connected dream... I like that! Whatever these Nightmares were, they sure picked a good duo to lure into an elaborate fantasy dream... A magical wind fish creature, and the legendary Hero of Hyrule...
BTW, Link's Awakening has the best ending in the series for this reason in my opinion.
A special one indeed --- which makes me wonder: have you expressed your LA ending love in this poll-thread