Herein we have demonstrated an electrochemical method for the synthesis of carbon-metal fluoride nanocomposites (CMFNCs). Electrochemical intercalation of transition metal ions into graphite fluoride (CF$_{x}$) resulted in the formation of CMFNCs. As a proof-of-concept, we have synthesized C-FeF$_{2}$ and C-NiF$_{2}$ nanocomposites by the electrochemical intercalation of Fe$^{2+}$ and Ni$^{2+}$ into CF$_{x}$ from corresponding non-aqueous electrolytes. The C-FeF$_{2}$ and C-NiF$_{2}$ nanocomposites synthesized by this method showed high reversible capacity and cycling stability compared to chemically synthesized analogs as cathode materials for lithium batteries. The reversible capacity of chemically synthesized C-FeF$_{2}$ is 181 mAh g$^{-1}$, whereas electrochemically synthesized material is 349 mAh g$^{-1}$ after 20 cycles. The better cycling performance of electrochemically synthesized C-FeF$_{2}$ was attributed to the homogeneous distribution of FeF$_{2}$ nanoparticles within the carbon matrix enabled by the electrochemical intercalation of Fe$^{2+}$. The electrochemical method described here is emission-free, cost-effective, occurs at room temperature, and extendable to the synthesis of several other CMFNCs. Moreover, it might provide new avenues for the synthesis of advanced functional materials.