Where can I get the Masterball?

In the Kanto region, you receive the Masterball after defeating Giovanni at the Silph Co.

In the Johto region, you receive the Masterball after talking to Prof. Elm in New Bark Town after getting all 8 gym badges.

You can receive Masterballs as prizes from loot boxes.

You can also trade for Masterballs with other players.

masterball