A mesoporous MoSe2/C composite is synthesized through a nano-casting technique along with heat treatment. Nano-silica particles are used as templates to create mesopores. Homogeneously dispersed Molybdenum and selenium particles in the starch substrate are reacted with each other to formed MoSe2 nanosheets when subjected to heat-treatment. Meanwhile, the starch is carbonized into carbon. The mesoporous MoSe2/C composite is investigated as an anode material for both lithium-ion batteries (LIBs) and sodium-ion batteries (SIBs). It presents good storage capacity for both lithium ions and sodium ions. Under the current density of 200 mA g−1, the mesoporous MoSe2/C composite exhibits reversible capacity of 618 mA h g−1 for LIBs and 360 mA h g−1 for SIBs after 300 cycles. The superior electrochemical performance could be ascribed to the mesoporous structure of MoSe2/C composite which provides sufficient space for accommodating huge volumetric expansion and the charge product, selenium.