The security of quantum key distribution (QKD) [1,2] usually relies on that the users's devices are well characterized according to the security models made in the security proofs [3]. In contrast, device-independent QKD [4-11] -an entanglement-based protocol [2] -permits the security even without any knowledge of the underlying devices. Despite its beauty in theory, device-independent QKD is elusive to realize with current technology. This is because a faithful realization requires a high-quality violation of Bell inequality without the fair-sampling assumption [12,13]. Particularly, in a photonic realization, a rather high detection efficiency is needed where the threshold values depend on the security proofs [7][8][9][10][11]; this efficiency is far beyond the current reach [12][13][14][15][16][17][18][19][20][21][22][23][24]. Here, both theoretical and experimental innovations yield the realization of device-independent QKD based on a photonic setup. On the theory side, to relax the threshold efficiency for practical deviceindependent QKD, we exploit the random post-selection [25] combined with adding noise [26] for preprocessing, and compute the entropy with complete nonlocal correlations [27]. On the experiment side, we develop a high-quality polarization-entangled photonic source and achieve state-of-theart (heralded) detection efficiency of 87.49%, which outperforms previous experiments [12][13][14][15][16][17][18][19][20][21][22][23][24] and satisfies the threshold efficiency for the first time. Together, we demonstrate device-independent QKD at a secret key rate of 466 bits/s over 20 m standard fiber in the asymptotic limit against collective attacks. Besides, we show the feasibility of generating secret keys at a fiber length of 220 meters. Importantly, our photonic implementation can generate entangled photons at a high rate and in the telecom wavelength, which is desirable for high-speed key generation over long distances. The results not only prove the feasibility of device-independent QKD with realistic devices, but also push the security of communication to an unprecedented level.