As said already, your story is taken from Þrymskviða. There's a retelling of the story named The Children of Odin, which refers to that in a more easily comprehensible way:
The actual story does not say that Loki stole the hammer from Thor.
Then when they were far from Jötunheim Thor missed Miölnir, missed the hammer that was the defence of Asgard and the help of the Gods. He could not remember how or where he had mislaid it. Loki's thoughts went toward Thrym, that stupid Giant who yet had cunning streaks in him. Thor, who had lost the hammer that he had sworn never to let out of his sight, did not know what to do.
But Loki thought it would be worth while to see if Thrym knew anything about it. He went first to Asgard.
The Children of Odin
By having a discussion with Thrym, the hammer's location is identified:
"Ha, Loki, Shape-changer," said Thrym, "you are there! But all your watching will not help you to find Miölnir.
I have buried Thor's hammer eight miles deep in the earth. Find it if you can. It is below the caves of the Dwarfs."
The Children of Odin
During the feast, where Thor and Loki are disguised, the Hammer is presented to Thor
.
Then Thrym, the stupidest of the Giants, rose up and brought Miölnir, the defence of Asgard, into the feasting hall. Thor could hardly restrain himself from springing up and seizing it from the Giant. But Loki was able to keep him still. Thrym brought over the hammer and put the handle into the hands of her whom he thought was his bride. Thor's hands closed on his hammer. Instantly he stood up. The veil fell off him. His countenance and his blazing eyes were seen by all. He struck one blow on the wall of the house. Down it crashed. Then Thor went striding out of the ruin with Loki beside him, while within the Giants bellowed as the roof and walls fell down on them. And so was Miölnir, the defence of Asgard, lost and won back.
The Children of Odin