The safety of lithium ion batteries has long been a critical obstacle for their high-power and large-scale applications because of the flammable nature of their carbon anode and organic carbonate electrolytes. To eliminate the potential safety hazards, lithium ion batteries should be built up with thermal-stable electrodes and nonflammable electrolytes. Here we report safer lithium ion batteries using nonflammable phosphonate electrolyte, thermal-stable LiFePO4 cathode and alloy anodes. Benefiting from the electrochemical compatibility and strong fire-retardancy of the phosphonate electrolyte, the cathode and anode materials in the nonflammable phosphonate electrolyte demonstrate similar charge–discharge performances with those in the conventional carbonate electrolyte, showing a great prospect for large-scale applications in electric vehicles and grid-scale electric energy storage.