First, get your IMEI number. You can either type *#06# then hit "send" on your cell phone, or you can look under the cell phone battery. For some reason the one I got from the screen was 2 digits longer than the one I got from the back of the battery. They only need the shorter one.
Second, you call ATT customer service at 800-331-0500. Ask them for the unlock code. In my case, I told them the old phone number it was under and they verified my account information my asking for the last 4 of the SS number of the main account holder.
You also have to know the model of your phone so they can give you instructions. This was also under the battery.
After a minute, the phone rep. will give you the unlock code (8 digits) and some instructions. They will also warn you that you only get 5 tries, and then your phone is permanently network locked.
For me, they gave me the following instructions:
Turn on the cell phone with the ATT old Sim card in it. Type #7465625*638*58051929#, then hit send. You will see the message that the phone is now network unlocked.
Then take out the old sim card insert the new one, and turn the phone back on. Try to make a call. At first, it didnt' work for me, and then the phone finally registered on the network with the name of the new carrier showing up on the screen. (I went from ATT to T-mobile - both GSM networks).
When you type that in, everything after the first * becomes - so you are typing "blind" so to speak. That is where it gets tricky and you might use up all 5 tries.
the last eight digits from the code above were my unlock code number. The #7465625*638* part is a model-specific code that prepares the phone for the unlock code.
Took about 5 minutes total. Thanks AT&T! I might use you again.
PS if you hard lock your phone, you can still use in on ATT, for instance on a Go-phone card.