The development of lead halide perovskite X-ray detectors has promising applications in medical imaging and security inspection but is hindered by poor long-term stability and drift of the dark current and photocurrent. Herein, we design a (Cs0.05MA0.65FA0.3)PbI3-(Cs0.1MA1.3FA0.6)AgBiI6 double-layer perovskite film to assemble a self-powered flat-panel X-ray detector. The demonstrated X-ray detector achieves an outstanding self-powered sensitivity of 80 μC Gyair-1 cm-2 under a 0 V bias. More importantly, owing to the inhibition of the phase transition process and ion migration of (Cs0.05MA0.65FA0.3)PbI3 by the (Cs0.1MA1.3FA0.6)AgBiI6 layer, the device exhibits excellent continuous operating stability with a retention rate of 99% dark current and photocurrent over X-ray pulses of up to 4000 s and excellent long-term stability without a loss of the original response current after 150 days in an air environment. The strategy of double-layer perovskites improves the stability and sensitivity of devices, which paves a path for the industrial application of lead halide perovskite X-ray detectors.