3D ordered porous structures of MoxC are prepared with different Mo to C ratios and tested for two possible promising applications: hydrogen evolution reaction (HER) through water splitting and lithium ion batteries (LIBs). Mo2C and MoC with 3D periodic ordered structures are prepared with a similar process but different precursors. The 3D ordered porous MoC exhibits excellent cycling stability and rate performance as an anode material for LIBs. A discharge capacity of 450.9 mA h g-1 is maintained up to 3000 cycles at 10.0 A g-1. The Mo2C with a similar ordered porous structure shows impressive electrocatalytic activity for the HER in neutral, alkaline and acidic pH solutions. In particular, Mo2C shows an onset potential of only 33 mV versus a reversible hydrogen electrode (RHE) and a Tafel slope of 42.5 mV dec-1 in a neutral aqueous solution (1.0 M phosphate buffer solution), which is approaching that of the commercial Pt/C catalyst.