I canβt say how Twilio does it, but we have been doing it for over a year ( http://tropo.com/ ) and I can explain how we do it.
We work with several SMS aggregators to actually deliver messages. Our numbers are included for SMS just like your mobile phone. When you send a text message to a number, the operator looks at how to deliver it, throws it at one of our aggregators, which, in turn, delivers it to one of our data centers. Shortcodes work the same with us.
In fact, mobile operators consider us to be just another mobile carrier.
source share