Right out of the box, it most likely will not, unless it was unlocked.
However, both AT&T and T-Mobile operate on the same type of network, GSM. So if you put in a SIM card from a T-Mobile phone into an AT&T phone, then it will most likely ask for the Unlock code. You can get this from different places, however T-Mobile is known to give people the code so that you can use it.
Addition: Answer 2
The Unlock code is slightly different than actually having the phone unlocked. To have it unlocked is something regarding the software inside the phone, that can be altered by a computer. The unlock code is just to access Phone restrictions and security features. MOST phones are locked, and cannot be swapped on sim cards. So far the only phone i have successfully made work on both providers is the Apple iPhone, and that was a Jail broken one.
Posted via Android Central App