**Mathematical model for real-world entanglement swapping and applications to practical long-distance quantum key distribution**

Entanglement swapping between photon pairs is a key building block in entanglement-based quantum communication schemes using quantum relays or quantum repeaters to overcome the range limits of long-distance quantum key distribution (QKD). We present a nonperturbative mathematical model for practical entanglement swapping, which accounts for real-world imperfections due to detector inefficiencies, detector dark counts and the unavoidable multipair events of current realistic sources of entangled photon pairs. Our closed-form solution for the actual quantum states prepared by realistic entanglement swapping is useful for planning long-distance QKD experiments. In particular, our analysis provides the optimal photon-pair production rate (brightness) of the sources that maximizes the secret key rate for a given distance between a sender (Alice) and a receiver (Bob).