Locate the iPhone IMEI number and make a note of it:
Tap Settings then tap General
Tap “About” and scroll down to find “IMEI”
Call AT&T either by dialing 611 from the iPhone, or call 1-800-331-0500 and then dial 0010 to immediately speak to a representative and skip the hold time (International users dial 1-800-335-4685)
Request your iPhone to be unlocked, provide the IMEI number of the device, and then wait for the instructions to be emailed to you
AT&T will initiate a request to unlock the iPhone and then you have to restore the iPhone through iTunes to complete the device unlock. With the device unlocked, a micro-SIM from T-Mobile or other compatible networks will now work in the iPhone.
The time it takes to receive the unlock instructions seem to vary widely, with requests being made earlier in the day being fulfilled sometimes with an hour, while later requests given up to two weeks wait time.