From Glitch City Laboratories
The Ditto Trick is one of the most useful glitches in the Generation I of Pokémon games, and is the only way to get most Glitch Pokémon without a game-altering device. It is a variation of the more well-known Mew Trick that takes advantage of Ditto's Transform instead of requiring that specific Trainers be encountered.
- Train a Pokémon so that its Special stat is equal to the decimal number of the Pokémon that you want to find with this trick; for example, if you want a Mew to appear, you need a Pokémon with a Special of 21. Don't put this specially trained Pokémon at the front of your party (see step 5), and make sure to have a Pokémon that knows Fly or Teleport into your party. If you are using Teleport, be sure that you have carefully planned the steps beforehand, as you cannot choose where you Teleport, and you also can only Teleport to one city at a time. If one is using Yellow Version, one should also have an Escape Rope or a Pokémon knowing Dig (see step 6).
- Find any Trainer that challenges the player right as he or she steps where they can see him or her (both characters should be on boundaries of the screen and facing each other). Save here, then take a step downwards into their line of sight, but press START in mid-step. The most well known trainer to do this with is the Gambler outside the Underground Tunnel, though it can be done with other trainers.
- The player should be standing where the trainer would normally be able to see and challenge him, but the START menu should be up and therefore he cannot. Select "POKéMON" and then have the player's Pokémon knowing Fly or Teleport use either move, taking you to another town. Any town will do, as long as there are trainers accessible from it which have not been beaten by the player.
- The START button now has no effect if pressed, and if the player tries to talk to people, they don't say anything. This is normal. The game expects a trainer battle to start since the player was seen by the Gambler. To get the START menu back, find any trainer that the player hasn't beaten, and walk at least 2 tiles in front of the trainer so that he or she walks up to you. One of the other strange side effects of this glitch is that the game will freeze if you walk directly in front of a trainer - that is, only 1 tile in front of them. If you used Teleport instead of Fly, it is important that you teleport to a location where wild Dittos can be found.
- Now, defeat the trainer in a battle. The reason the Pokémon with the specific Special stat should not be in front is that without the START menu, it can not be moved lower in your team, thus always gaining experience during this battle, and maybe leveling up, changing its Special stat.
- After beating the trainer, the START menu should once again be usable. Use it to Fly to Fuschia City (in Red/Blue) or to Cinnabar Island (in Yellow). Look in the grass on the route to the east of Fuschia (in Red/Blue) or in the basement floor of Pokémon Mansion (in Yellow) until the player finds a Ditto. When you do, switch to the Pokémon with the specific Special stat and let Ditto Transform into it. Then, run away. This glitch must be finished without encountering any other Pokémon. In Yellow Version, this can be a problem, because it's nearly impossible to get out of Pokémon Mansion without encountering wild Pokémon. This is why the player should have an Escape Rope or a Pokémon with Dig.
- Fly to the town nearest to the route where the player flew away from the first trainer (Lavender Town if the Gambler was used) and walk onto this route. As soon as you enter it, the START menu should appear. Close it with B or by selecting "Exit", and a wild Pokémon should appear - exactly the one whose decimal number matches your Pokémon's Special stat. If you used Teleport, this is where things can become difficult, as the player can not Teleport back to the town where the trainer was, so the player must walk or bike back. Do not face any trainers or wild Pokémon until the player reaches the route where the trainer originally fought was.
Alternative method (with an unlimited amount of uses)
If the player wants to perform the Ditto Trick for a multiple amount of times, there is an alternative method for performing the Ditto Trick with no limit. For this, the player can battle the Gary from the Elite Four; since he can be fought for an unlimited amount of times, the player can also use this method to encounter an unlimited amount of Pokémon.
- Train a Pokémon so that its Special stat is equal to the decimal number of the Pokémon that the player wants to find and keep that Pokémon in your party (but preferably it should not be placed as the first Pokémon in the party).
- Fly away from the same Gambler (or other usable trainer) as in the original method as soon as he sees you.
- Enter the Pokémon Center. Go and use the PC and change boxes to save the game, because the player is currently unable to open the start menu.
- Turn the game off and back on again. The start menu works again, and the player can do everything normally, including fighting by talking to other trainers.
- Fight a trainer who can be battled for an unlimited amount of times, such as Gary when the player defeats all of the Elite Four.
- Find a Ditto, let it Transform into the Pokémon with a Special stat which matches to a desirable Pokémon, run, and then fly to Saffron or Lavender.
- Go back to the Gambler's (or other trainer's) route, press "B", and fight the chosen Pokémon.
Getting Pokémon at level 100 with this trick
The level of the Pokémon encountered through the Ditto Trick is equal to the Attack modifier (not the stat itself) of the Ditto at the conclusion of the battle. Stat modifiers start at 7, hence why most Pokémon reported from this glitch are at level 7. The range of stat modifiers is from 1 to 13. In addition, Pokémon with a "fading growth pattern" (Mew and all 3-stage evolutionary lines excluding Butterfree, Beedrill, and Dragonite), due to a bug in the algorithm (1.2L3 - 15L2 + 100L - 140) used to calculate these Pokémon's experience points, have negative experience at levels below 2 (-54 at level 1, -140 at level 0). However, since level values are read as unsigned (i.e. non-negative) integers, this actually equates to a rather large positive number (16,777,076 and 16,777,162, respectively). If this Pokémon gains enough experience in battle to stay below 1 (i.e. less than 54), the game will recalculate its level based on experience, forcing the Pokémon to level 100, the maximum level that can be attained in battle. A video of this is located here: 
Removing overworld Pokémon
After the player flies away from a trainer (before he or she walks up to the player and battles him/her), if the player manages to approach an overworld Pokémon such as one of the two Snorlax near Lavender Town, it will not appear because the game will presume that the player is already in battle. If Teleport or Dig is used instead of Fly (which requires a Gym Badge later on in game) the player can pass Snorlax without recieving the PokéFlute, provided that the player does not actually battle any trainers on the way. If he or she does, the game will presume that the player is in the overworld again and overworld Pokémon will return presuming that the player has not actually battled it before. 
If a Pokémon with a Special stat above 255 is used for this glitch, the numbers loop back to 0 after 255. For instance, if a Pokémon with Special 300 is used, the HEX value applying to this glitch would be 44.