Maz Kanata was a Force-sensitive humanoid female who was born over a millennium before the brewing war between the First Order and the Resistance. Living in an ancient castle on the planet Takodana, Kanata gained a reputation as a "pirate queen" by allowing traveling smugglers to reside in her home—as long as they honored her prohibitions against politics and war. Kanata spent centuries traveling the galaxy, collecting antiques and trinkets which she kept inside the storehouses and vaults of her castle. One notable item was the lightsaber crafted by Jedi Knight Anakin Skywalker during the Clone Wars, and later wielded by Skywalker's son, Luke, who was instrumental in toppling the Galactic Empire.
Thirty years after the Empire's defeat at the Battle of Endor, the smuggler Han Solo brought Rey, a scavenger from the desert planet Jakku, to Kanata's castle. Kanata took interest in the girl, and when the Skywalker lightsaber called out to Rey through the Force, the smuggler queen told the scavenger to keep the weapon. However, Rey refused, and shortly before stormtroopers of the First Order arrived looking for her she fled the castle. During the ensuing battle, Kanata's castle was destroyed, and Rey was taken prisoner, so Kanata entrusted the lightsaber to Finn, a former First Order stormtrooper who abandoned his previous occupation, choosing to help the Resistance.