Can i legally sell a contract phone that i got free with my contract?

I got an xda orbit phone free with a new pay monthly contract from o2. can i sell the phone legally, but obvisouly keep the contract sim to use in another phone? might sound a silly question, but someone told me that i couldnt, and i thought i could as im paying for the contract sim, the phone was free!
Answer
Even if you got it subsidized, the carrier is getting their money out of the contract and you legally own the phone.feel free to sell it!