Highly porous carbide-derived carbon (CDC) mesofoams (DUT-70) are prepared by nanocasting of mesocellular silica foams with a polycarbosilane precursor. Ceramic conversion followed by silica removal and high-temperature chlorine treatment yields CDCs with a hierarchical micro-mesopore arrangement. This new type of polymer-based CDC is characterized by specific surface areas as high as 2700 m2 g−1, coupled with ultrahigh micro- and mesopore volumes up to 2.6 cm3 g−1. The relationship between synthesis conditions and the properties of the resulting carbon materials is described in detail, allowing precise control of the properties of DUT-70. Since the hierarchical pore system ensures both efficient mass transfer and high capacities, the novel CDC shows outstanding performance as an electrode material in electrochemical double-layer capacitors (EDLCs) with specific capacities above 240 F g−1 when measured in a symmetrical two-electrode configuration. Remarkable capacities of 175 F g−1 can be retained even at high current densities of 20 A g−1 as a result of the enhanced ion-transport pathways provided by the cellular mesostructure. Moreover, DUT-70 can be infiltrated with sulfur and host the active material in lithium–sulfur battery cathodes. Reversible capacities of 790 mAh g−1 are achieved at a current rate of C/10 after 100 cycles, which renders DUT-70 an ideal support material for electrochemical energy-storage applications.