The information below will help, but there is now additional information on rice baths and using water vs. alcohol to clean electronics. Please read more from iFixit for more detailed information.
DON'T ATTEMPT TO APPLY ANY POWER
Separate the phone into as many parts as you can (i.e. take the battery out, back cover off) without taking screws out.
Cover the device fully with dry rice. Try three days, this gives the water time to evaporate, hopefully, aided by the rice.
Reassemble and try the device again.
If this doesn't work, there are a few more things to try, but chances are you're out of luck :/
IF YOU WISH TO BE EXTREME, or have spilled corrosive material (soda, juice, etc.)
Note, I have a friend that has done this successfully several times, and even though it sounds scary, it has worked for many people:
First, take out the battery
Second, check to make sure you took out the battery
Next, submerge the phone (without the battery) completely in deionized water (distilled should be fine). Leave it there for 24 hours.
ALTERNATIVELY: washing the internals with 90% or higher isopropyl alcohol will clean the device just as well, and evaporate much quicker, without the need for a rice soak.
After waiting such a time, remove the phone, scrub the board with alcohol to remove any corrosion, still, do not replace the battery and cover it completely in dry rice for three times (or a week, to be safe) the amount of time you had it in the water
This process should clean the inside of your phone and hopefully remove any salinity, and should not harm the phone as long as there is no power applied to the device, i.e. the battery