G.39.1- You may not announce a targeted spell or ability unless you can choose a legal target. [CompRules 1999/04/23]
G.39.2- If a spell or ability has you (or other players) pick multiple targets, the same target may not be picked more than once. There is an implied "multiple different targets". [CompRules 1999/04/23]
G.39.3- If a spell or ability's resolution has you pick target(s) for an additional effect, you may choose the same target(s) that the original effect chose. [Mirage, Page 58]
G.39.4- In addition to having a legal target when announced, a spell or ability checks its target to see if it is legal before it resolves. If its target is not legal, then the spell or ability does nothing with respect to that target. [CompRules 1999/04/23]
G.39.5- If a spell or ability has multiple targets and one or more of the targets become illegal prior to resolution, then the spell or ability still resolves with respect to its legal targets. [CompRules 1999/04/23] For example, a Fireball is cast targeting three creatures with 2 damage each. If one creature is Unsummoned, then nothing happens to that creature, but the other two creatures still take 2 damage each.
G.39.6- If all of the targets are illegal upon resolution, then any untargeted portion of the spell or ability is also ignored because the spell or ability is countered. [CompRules 1999/04/23] For example, Crumble targets an artifact to be destroyed and has an untargeted gaining of life. If the target becomes invalid, then no life will be given.
G.39.7- If a spell or ability allows you to change the target of another spell or ability, the new target must be a legal choice. If the choice was legal on announcement, but not on resolution, then the target is not changed. [CompRules 1999/04/23]
G.39.Ruling.1- There are many ways to make a target illegal before resolution. The most common way is for the target to be destroyed, sent a player's hand, or otherwise removed from play prior to resolution. Other requirements on the targeting may be invalidated due to adding Protection (see Rule A.31) to a target creature. [D'Angelo 1998/02/03]
G.39.Ruling.2- You may not announce a targeted spell declaring an illegal target with the intent to use a spell or ability afterward to somehow make the target legal. [D'Angelo 1998/02/03]
G.39.Ruling.3- During targeting checks, the current game state is always used. This is usually obvious, but in cases where indirect information is asked for (such as "the card target spell is targeting") it might be tempting to apply the last known information rule, but this is not correct. [Barclay 2002/02/12]
Note- Some spells are modal in their targeting. See Rule G.24.
Note- See the announcing (see Rule T.4) and resolution (see Rule T.6) steps of the spell life cycle for more information.