If you say you got it from Ebay, T-Mobile will tell you to go to Paypal or Ebay to get your money back.
I would suggest that you contact Ofcom for advice on 020-7981-3040, or try
www.ofcom.org.uk
T-Mobile as well as the other mobile network operators reserve the right to suspend accounts as well as block handsets which are believed to be lost,stolen or have been subject to fraud. The police may be involved.
I would suggest you write to T-Mobile and request an unblock, together include your name,address,contact telephone number(Mobile and Landline), Email address if you have one and include the approximate dates you loaned the phone to your friend, together you will need to enclose evidence (photocopies) of phone ownership, and don't forget the IMEI number.
In your letter, you should also state a time limit to have the phone made right, give them 30 days and threaten to take legal action to gain compensation. Since it's your property, they can't leave it like that permanently!