Warranty goes with the iPhone but is only valid in the Country where that part number is designated for sale. So if you buy a second-hand iPhone 3G S in the USA, then the warranty is only valid in the USA.
Also, Apple is the warranty service agent for all iPhones in the USA, you may need to provide a vaild AT&T phone number for warranty service, this varies by store / region / individual Apple "Genius".
Dave