A novel nitrogen-doped porous graphene material (NPGM) was prepared by freeze-drying a graphene/melamine-formaldehyde hydrogel and subsequent thermal treatment. The use of melamine-formaldehyde resin as a cross-linking agent and nitrogen source enhances the nitrogen content. NPGM possesses a hierarchical porous structure, a large Brunauer-Emmett-Teller surface area (up to 1170 m2 g-1), and a considerable nitrogen content (5.8 at%). NPGM displays a discharge capacity of 672 mA h g-1 at a current density of 100 mA g-1 when used as an anode material for lithium ion batteries, much higher than that observed for a nitrogen-free graphene porous material (450 mA h g-1). The NPGM electrode also possesses superior cycle stability. No capacity loss was observed even after 200 charge/discharge cycles at a current density of 400 mA g-1. The enhanced electrochemical performance is attributed to nitrogen doping, high specific surface area, and the three-dimensional porous network structure.