Nobody knows for sure how Maz Kanata got Luke Skywalker's lightsaber. The film never explains it, and Maz herself calls it a story for another time. What we do know is where the saber was lost, where it turned up, and the handful of explanations people have floated since.
Luke's lightsaber, Anakin's lightsaber
People search for this both ways, so to be clear: it's the same saber. It started out as Anakin Skywalker's, and then it became Luke's. If you've been wondering how Maz got Anakin's lightsaber, you're asking the same question, and the answer's the same too. Our guide to every lightsaber Anakin carried covers the earlier part of the trail.
The lost lightsaber
Luke lost it on Cloud City in The Empire Strikes Back, when Darth Vader cut off his hand and the hand, still holding the lightsaber, fell away. For Return of the Jedi Luke built a green one, and the original disappeared. (If the blue and green are bugging you, what every lightsaber color means sorts it out.)
The basement on Takodana
In The Force Awakens, Rey follows a sound into the basement of Maz's castle and finds a chest. Inside is the lightsaber, and when she touches it she gets the burst of visions that kicks off the sequel trilogy. Maz tells her it belonged to Luke, and to his father before him. When Rey asks how Maz ended up with it, the answer is a story for another time, and the movie never goes back to it.
The theories
Canon hasn't given a settled answer. A 2020 Marvel comic shows a hooded figure catching the lightsaber as it falls from Cloud City, but it doesn't say who that is, and tying it to Maz is speculation. Another popular idea is that someone on Cloud City, like an Ugnaught, found it and kept it, which is a theory and not an official answer. Fans also point out that Maz is a pirate with a huge collection of artifacts and contacts across the galaxy, so a saber like that could easily have drifted her way. And J.J. Abrams has said he once planned to show the saber's journey from Cloud City to Maz, but the scene didn't make the film.
Why it matters
The saber's the bridge between the old trilogy and the new one. It passes from Anakin to Luke to Rey, and Rey keeps and uses it, including in the forest fight with Kylo Ren. For a look at Kylo's own weapon, see Kylo Ren's lightsaber.
If you want a Skywalker-style saber, our Anakin lightsabers and the Luke lightsaber are the closest things we have. They're inspired by the characters, not official. And the best lightsaber for dueling can help you choose a blade type.