After being unable to sleep one night, Loki headed down to the weapons vault, where he received a warning from the Tesseract about Thanos having attacked the planet known as Xandar in an attempt to take the Power Stone that was hidden there. Panicked, he called for Juliet and Thor to meet him down in the vault, and when they arrived, he explained the situation to them, hoping they would be able to help come up with a plan of attack. The group all agreed not to let Thanos get to the Infinity Stone on Xandar, and the suggestion to bring an additional person to help was made. Thor suggested Loki's pyrokinetic assistant Dagmar, but he disagreed, and suggested they bring along his twin sister instead, with whom he had been training with in secret ever since she had been imprisoned for her misguided attack on the palace. Thor was hesitant, but Juliet agreed, and while they prepared the remainder of Asgard for their absence, Loki headed to the prisons to ask for his sister's help. She refused at first, but when he promised her freedom upon survival of the mission, she changed her mind, and the group left Asgard via one of Loki's portals.
Arriving on Xandar to see Thanos' Black Order fighting the Xandarians, Loki, Juliet, and Aela stole one of the Black Order's ships while Thor stayed behind on Xandar to help with the fight. The trio then headed up to Thanos' main ship, which they found empty. Suspicious, they exited the smaller ship, and were soon after faced with Proxima Midnight and Corvus Glaive, two of Thanos' best fighters. Aela attacked Corvus without waiting for permission, and Loki and Juliet were left to fight Proxima, who Juliet killed after managing to steal her staff. The trio then continued their search for Thanos throughout the ship, with Proxima's staff now in their possession.
When they eventually found Thanos further in the ship, Loki's panic spiked, and he tried to flee while Juliet confronted the Titan, but was stopped by his sister. He then opted to watch while the two conversed, but when Juliet mouthed off one too many times, she was thrown aside, and Loki ran to her aid. She was alive, but unconscious, and the attack on her prompted Loki to have Aela attack Thanos. Rather than join her, however, he stuck to the sidelines to wait for an opportunity to jump in and steal the Infinity Gauntlet, despite the fact that it had no Stones in it. Unsurprisingly, no such opportunity presented itself, and he was forced to join the fight in order to save Aela from being killed. The twins then attempted to work together, but that attempt failed when Aela was thrown aside in a similar fashion as Juliet, leaving Loki to face Thanos on his own. Rather than attack, however, Thanos attempted to make deal for the Tesseract, which Loki was quick to point out was not an Infinity Stone like originally assumed. Thanos knew this, however, and attacked shortly after, knocking the god aside before picking him up to taunt him, as well as threaten him for the Tesseract one last time. Rather than hand it over, however, Loki used the opportunity to knock Thanos back with his helmet, and then attempted to strangle him while in his Jotun form due to an overly emotional state having been brought on. That attempt failed, but he managed to kill Thanos by decapitating him with a sword made of ice shortly after, thus ending the fight and saving the galaxy from destruction.
Afterwards, Loki returned to Xandar, successfully ending the fighting there when he threw Thanos' severed head in front of his army. They scattered, and after receiving many thanks from the Xandarian citizens, Loki, Thor, Juliet, and Aela returned home, where Loki placed the Infinity Gauntlet in the weapons vault with the other artifacts that'd been collected there over the years.