In Norse mythology, Útgarða-Loki (Anglicized as Utgarda-Loki and Utgard-Loki) was the ruler of the castle Útgarðr in Jötunheimr. He was one of the Jötnar and his name means literally "Loki of the Outyards," to distinguish him from Loki, the companion of Thor.
According to the Prose Edda book Gylfaginning, Thor, Þjálfi and Loki, during their travel to Útgarðr, unwittingly settle for the night and sleep in the glove of a giant named Skrýmir ("Big-looking"), an incident for which Thor is ridiculed in several poems of the Poetic Edda. The giant accompanies them on their travel and tricks their food from them. Starved and in rage, Thor tries to kill Skrýmir while the giant sleeps, but fails because the giant magically shields himself behind a mountain.
Once Thor and his fellows arrive at Útgarða castle, which is so tall that they must bend back their necks to see its roof, Útgarða-Loki challenges them with several contests, all based on magical delusions. Loki participates in an eating contest against fire personified. Þjálfi competes in running against the mind of Útgarða-Loki. Thor first tries to empty a drinking horn connected to the sea, then tries to lift Jörmungandr in the appearance of a cat, and finally, in rage, wrestles with Elli, Old Age personified.
Despite their failures in the contests, Útgarða-Loki now treats them respectfully. As they leave the castle the next morning, Útgarða-Loki says:
nú skal segja þér hit sanna, er þú ert út kominn or borginni, at ef ek lifi ok megak ráða, þá skaltu aldri optarr í hana koma; ok þát veit trúa mín, at aldri hefðir þú í hana komit, ef ek hefða vitat áðr, at þú hefðir svá mikinn krapt með þér, ok þú hafðir svá nær haft oss mikilli ófœru. Enn sjónhverfingar hefi ek gert þér, svá at fyrsta sinn, er ek fann þik á skóginum, kom ek til fundar við yðr; ok þá er þú skyldir leysa nestbaggann, þá hafðak bundit med gresjárni, enn þú fannt eigi, hvar upp skyldi lúka. [...] Enn er þú drakkt af horninu, ok þótti þér seint liða; en þát veit trúa min, at þá varð þat unðr, er ek munda eigi trúa at vera mætti; annarr endir hornsins var út i hafi, enn þat sáttú eigi; enn nú, er þú kemr til sjávarins, þá muntú sjá mega, hvern þurð þú hefir drukkit á sænum; þat eru nú fjörur kallaðar.