Can I unlock my iphone in the middle of my contract?

I have an extra iPhone 4S that I want to give to my friend to use. But her network is tmobile so I need to get it unlocked. I want to get it factory unlocked but I'm in the middle of a contract with AT&T. Is it possible to use an online unlock service (such as global unlocks) even though I'm still on contract?

AT&T iPhone won't work with T-Mobile. Go sale the phone you have at GameStop. Than go and buy an iPhone for t-mobile.