The capacity of ad hoc wireless networks can be substantially increased by equipping each network node with multiple radio interfaces that can operate on multiple nonoverlapping channels. However, new scheduling, channel-assignment, and routing algorithms are required to fully utilize the increased bandwidth in multichannel multiradio ad hoc networks. In this paper, we develop fully distributed algorithms that jointly solve the channel-assignment, scheduling, and routing problem. Our algorithms are online algorithms, i.e., they do not require prior information on the offered load to the network, and can adapt automatically to the changes in the network topology and offered load. We show that our algorithms are provably efficient. That is, even compared with the optimal centralized and offline algorithm, our proposed distributed algorithms can achieve a provable fraction of the maximum system capacity. Furthermore, the achievable fraction that we can guarantee is larger than that of some other comparable algorithms in the literature.