Onion routing is an anonymous communication technique that encrypts and routes traffic through multiple network nodes, making it difficult to trace. It works by having a client connect to a Tor network node, which encrypts the connection and passes it to another node, and so on through several nodes, with each node only knowing the previous and next hops. This creates an encrypted circuit through the network that separates identification of the user from message routing to provide anonymity.