The events of Avengers: Infinity War and Endgame are centered around Marvel's Infinity Stones. The Infinity Stones' timeline features the powerful gems both in end credits cameos and central storylines. The Stones play an essential role for MCU characters and fans have posited a slew of Marvel fan theories about how the universe will be rescued from Thanos's snap - some more believable than others.
The MCU timeline is convoluted, however, and casual viewers might need a refresher on how each of the Stones ends up in Thanos's Gauntlet in the first place. Not to worry, there is an explanation for those of you looking for a quick overview of the history of the Infinity Stones in the MCU.
Where We First See It In The MCU: Thor
Who Has Had A Part In Its History: The Space Stone, as the Tesseract, was hidden on Earth by Odin long ago. We first see it come into play in Captain America: The First Avenger when the Red Skull unearths it during WWII. While attempting to launch a strike on the US, the Red Skull is intercepted by Captain America. Upon grabbing the Tesseract, the Red Skull is teleported away, and the cube burns a hole through the bottom of the plane it's on and falls into the Arctic Ocean. Howard Stark later recovers the Tesseract while looking for Steve Rogers and it ends up with S.H.I.E.L.D.
In Captain Marvel, Dr. Wendy Lawson uses the Tesseract as a part of Project P.E.G.A.S.U.S in the 1980s. She attempts to create a light-speed engine to help the Skrulls. When Yon-Rogg tries to take the object, Goose swallows it for safekeeping.
Goose returns the Tesseract to S.H.I.E.L.D. who begin testing its capabilities in the reactivated Project P.E.G.A.S.U.S. In the mid-credits scene of Thor, Loki manages to influence Dr. Erik Selvig, who is assigned to study the Tesseract. During The Avengers, Loki creates a wormhole so he can use his Chitauri army to gain control of the Earth. In exchange for the army, he agrees to give the Tesseract to Thanos - though he's defeated by the Avengers and both Loki and the Tesseract are taken to Asgard.
Where It Was Before Thanos Got It: Loki grabs the Tesseract from Asgard just before it's wiped out in Thor: Ragnarok. Loki attempts to trick Thanos when he comes looking for it, but Thanos sees through his plan and takes the Space Stone by force.
Where We First See It In The MCU: The Avengers
Who Has Had A Part In Its History: The Mind Stone is originally a part of the Scepter, which Loki uses to control the scientists working on Project P.E.G.A.S.U.S in The Avengers. Thanos gives the trickster god the device to help him conquer Earth. After Loki is defeated, S.H.I.E.L.D. takes the Scepter; Wolfgang von Strucker gets possession of it thanks to the sleeper agents within the agency. He uses it to conduct human experimentation - primarily involving Wanda and Pietro Maximoff.
The Avengers later raid von Strucker's base in Avengers: Age of Ultron and retrieve the Specter. Thor allows Tony Stark to research the Mind Stone within, and he and Bruce Banner use it for the Ultron Program. Once Ultron is activated, he takes the device, breaks the Specter, and removes the Stone to activate a new vibranium body. The Avengers take the body and help create Vision - who is granted consciousness thank to the Stone housed in his forehead.
Where It Was Before Thanos Got It: Vision still possesses the Mind Stone when the Black Order confronts him. He travels to Wakanda to try to have the Stone removed but is interrupted by Thanos. Vision convinces Wanda to eliminate both him and the Stone, but Thanos uses the Time Stone to reverse the action. He then removes the Mind Stone from Vision's forehead and completes the Infinity Gauntlet.
Where We First See It In The MCU: Thor: The Dark World
Who Has Had A Part In Its History: Thousands of years in the past, Malekith the Accursed uses the Reality Stone to create the Aether and attempts to wipe out the Nine Realms. The Asgardians defeat him, only to return in the modern day and try again. After he's stopped by Thor, the Aether is sealed in a container and given to The Collector for safekeeping. Thor has a dream in Age of Ultron about the end of the world and sees the Aether solidify to become the Reality Stone.
Where It Was Before Thanos Got It: The Aether is with the Collector until Thanos takes it and materializes the Reality Stone.
Where We First See It In The MCU: Guardians of the Galaxy
Who Has Had A Part In Its History: During a mission, Star-Lord finds the mysterious Orb and attempts to sell it to keep it out of Ronan the Accuser's possession. Star-Lord hooks up with the future members of the Guardians of the Galaxy and they eventually take the Orb to The Collector - who opens it to reveal the Power Stone. After his assistant fails to take it, Ronan and Nebula successfully grab the Stone from The Collector. Ronan creates a tool of chaos by combining the Stone with his Cosmi-Rod.
The Guardians track him down and, together, harness the power of the Stone to defeat Ronan. The Stone is placed in a new container and given to the Nova Corps for protection.
Where It Was Before Thanos Got It: The Power Stone is housed in the Nova Corps vault on Xandar. Sometime before the events of Avengers 3, Thanos goes to the planet and decimates it to retrieve the stone for himself.