The phone is probably locked so it won't work. To make sure, take a T-Mobile SIM and put it in the phone. If it works is ok, if not you need to unlock the phone.
The phones are usually locked in the network until the contract on which is was acquired expires. Ask your friend to call AT&T and ask them about the unlocking options.