Nano SiO2–P(VDF-HFP) composite porous membranes were prepared as the matrix of porous polymer electrolytes through in situ composite method based on hydrolysis of tetraethoxysilane and phase inversion. SEM, TEM, DSC and AC impedance analysis were carried out. It is found that the in situ prepared nano silica was homogeneously dispersed in the polymeric matrix, enhanced conductivity and electrochemical stability of porous polymer electrolytes, and improved the stability of the electrolytes against lithium metal electrodes. The in situ composite method was found to be much better than the direct composite method in lowering the interfacial resistance between electrolyte and lithium metal electrode. Moreover, cycle test of lithium batteries using lithium metal as anode and sulfur composite material as cathode showed that the electrolyte based on in situ composite of silica presented stable charge–discharge behavior and little capacity loss of battery.