From chapter 42 of the Gylfaginning in the Prose Edda by Snorri Sturluson, available online here. This online version is a transcript of The Prose Edda of Snorri Sturluson, translated by Arthur Gilchrist Brodeur, copyright 1916, pp. 54 – 56. It is in quotations because Harr is telling the story to Gylfi:
"It was early in the first days of the gods' dwelling here, when the gods had established the Midgard and made Valhall; there came at that time a certain wright and offered to build them a citadel in three seasons, so good that it should be staunch and proof against the Hill-Giants and the Rime-Giants, though they should come in over Midgard. But he demanded as wages that he should have possession of Freyja, and would fain have had the sun and the moon. Then the Æsir held parley and took counsel together; and a bargain was made with the wright, that he should have that which he demanded, if he should succeed in completing the citadel in one winter. On the first day of summer, if any part of the citadel were left unfinished, he should lose his reward; and he was to receive help from no man in the work. When they told him these conditions, he asked that they would give him leave to have the help of his stallion, which was called Svadilfari; and Loki advised it, so that the wright's petition was granted. He set to work the first day of winter to make the citadel, and by night he hauled stones with the stallion's aid; and it seemed very marvellous to the Æsir what great rocks that horse drew, for the horse did more rough work by half than did the wright. But there were strong witnesses to their bargain, and many oaths, since it seemed unsafe to the giant to be among the Æsir without truce, if Thor should come home. But Thor had then gone away into the eastern region to fight trolls.
"Now when the winter drew nigh unto its end, the building of the citadel was far advanced; and it was so high and strong that it could not be taken. When it lacked three days of summer, the work had almost reached the gate of the stronghold. Then the gods sat down in their judgment seats, and sought means of evasion, and asked one another who had advised giving Freyja into Jötunheim, or so destroying the air and the heaven as to take thence the sun and the moon and give them to the giants. The gods agreed that he must have counselled this who is wont to give evil advice, Loki Laufeyarson, and they declared him deserving of an ill death, if he could not hit upon a way of losing the wright his wages; and they threatened Loki with violence. But when he became frightened, then he swore oaths, that he would so contrive that the wright should lose his wages, cost him what it might.
"That same evening, when the wright drove out after stone with the stallion Svadilfari, a mare bounded forth from a certain wood and whinnied to him. The stallion, perceiving what manner of horse this was, straightway became frantic, and snapped the traces asunder, and leaped over to the mare, and she away to the wood, and the wright after, striving to seize the stallion. These horses ran all night, and the wright stopped there that night; and afterward, at day, the work was not done as it had been before. When the wright saw that the work could not be brought to an end, he fell into giant's fury. Now that the Æsir saw surely that the hill-giant was come thither, they did not regard their oaths reverently, but called on Thor, who came as quickly. And straightway the hammer Mjöllnir was raised aloft; he paid the wright's wage, and not with the sun and the moon. Nay, he even denied him dwelling in Jötunheim, and struck but the one first blow, so that his skull was burst into small crumbs, and sent him down bellow under Niflhel. But Loki had such dealings with Svadilfari, that somewhat later he gave birth to a foal, which was gray and had eight feet; and this horse is the best among gods and men. So is said in Völuspá:
Then all the Powers strode | to the seats of judgment,
The most holy gods | council held together:
Who had the air all | with evil envenomed,
Or to the Ettin-race | Ódr's maid given.
Broken were oaths then, | bond and swearing,
Pledges all sacred | which passed between them;
Thor alone smote there, | swollen with anger:
He seldom sits still | when such he hears of."