The Master Ball is a type of Poké Ball
In a wild encounter, it can catch a single wild Pokémon without fail (with the exception of the ghost Marowak in Pokémon Tower and other encounter Pokémon if it’s in the semi-invulnerable turn of an attack, such as bosses)
You are presented a Masterball after defeating Giovanni at Silf Co.
Professor Elm will give you a Masterball in New Bark Town, after all eight Johto badges are completed.
As with most items, Masterball’s can also be obtained by chance through Loot Boxes.
It is also possible to buy these Pokeballs from players via trade, Prices vary but usually around 25k Pokedollars