It does this by routing all(1) of your traffic through a series of constantly shifting peers that don't keep records or logs and don't use standard http ports.
Instead of YOU->ISP->Yahoo your traffic looks like YOU(encryption)->BOB->ALICE->STEVE(decryption)->Yahoo. Your ISP (and therefore your rotten government) only sees you make an encrypted connection to Bob, not a web request to yahoo. The chain is long enough that its really tough for anyone in the chain to figure out who you are and what your final destination is.
(1) Tor can be tricky to set up and know its working properly for the uninitiated. It can... leak if set up wrong, and certain protocols (like all UDP) are not well supported.