This paper presents a hybrid simulation/analytic model for the analysis and design of unreliable production lines with buffers and discrete workparts. The production rates of machines are deterministic and generally not equal. Using a discrete-event systems notation, the system is decomposed into one segment which is tractable by simulation and another one tractable by analysis. The key to this separation, resulting in reduced computation burden, is the definition of events, namely a machine fails, a machine is repaired, a buffer fills up, a buffer empties, a buffer becomes not full, and a buffer becomes not empty. The model is exact and much faster than conventional piece-by-piece simulators. It can analyze, efficiently and accurately, lines of any size during either transient or steady-state periods by taking into account effectively all transients associated with the function of the line. It is demonstrated that the model is superior to both brute-force and event-driven models that appeared in the literature recently, and therefore an efficient practical tool in the analysis and design of production lines. By incorporating the perturbation analysis technique into the proposed algorithm, the gradient estimation of the system's throughput can be performed during a single simulation run for various design parameters. A number of experimental results are reported for the repair allocation problem and the optimality of various control policies is investigated.