The story goes that once a man by the name of Hrimthurs claimed to the gods that he could build the walls within a single winter, but for a price. If he completed, then the gods would have to give him the Sun and the Moon for compensation as well as Freyja for a wife.
Loki was convinced that he could never finish them on time and got the gods to accept the wager. What the gods did not know was that Hrimthurs could do so, since he wasn’t a human. He was actually a giant and had a magical horse called Svadilfari. This horse could move huge blocks with magical ease.
When the winter was just about coming to an end, Hrimthurs had nearly completed the task on hand. The gods realised they were in trouble and that they would have to part with the prised possession of the Sun and Moon and above all, the goddess Freyja. All the gods approached Loki to bail them out, since it was anyway he who had convinced them into this.
Loki, true to his self, changed himself into a beautiful mare and went on to distract Hrimthurs horse, Svadilfari. Svadilfari began to chase Loki who was in the form of a mare, leaving Hrimthurs to fend for himself! Without the horse, he could not complete his task and lost the wager. When Hrimthurs come to know of the truth, he threatened to destroy his work, and in his rage, he lost his disguise, revealing to all that he was no human but a giant.
This Nordic myth has similarities to the Indian myth of amrut-manthan, where the demons disguise as gods to drink the nectar (as compared to the giant disguising as human here) to achieve immortality (here to gain the Sun, Moon as well as goddess Freyja). In the amrut-manthan, Vishnu disguises as Mohini to distract the demons, and here we have Loki disguised as a mare to distract the giant’s stallion. Just as the union of the horse and Loki as the mare gives birth to an eight-legged horse, Sleipnir, which becomes dear to Odin, in amrut-manthan we have seen, how the union of Shiva and Vishnu as Mohini gives birth to Lord Ayappa!