How to unlock an AT&T iPhone 4S to work on T-Mobile?

I want to get an iPhone 4s but all the ones I can afford (might) be locked to AT&T. In the case that they all are, how can I use it on my T-Mobile sim card?

Needs to have a clean serial number. You can check that here:
http://swappa.com/esn
If it's not, walk away. Needs to have iCloud info removed or it will never function unlocked or not.
Once verified as ATT, and it shows as clean and clear, have seller contact ATT and have them unlock it. Co's usually prefer to have the original owner or account holder do this to prevent hassle. They don't like getting involved in third party transactions. Apple won't either.
If seller can't unlock, you'll have to find or purchase unlock software to make this happen.
http://unlockios7.unlockboot.com/68296-unlock-at-t-iphone-5s-5c-4s-5-4-by-imei-code
Once unlocked setting up with Tmobile sim and network settings shouldn't be hard at all. Best luck.
http://support.t-mobile.com/...age/325628

You can get a free unlock from ATT OR GO TO Http://www.freeunlock.us

If you can't do it directly through At&t for whatever reason, order express unlock at http://attunlocker.us I just used themto unlock my iPhone 5 and it works like charm. It's a bit expensive but is worth every penny.