We report the results of a systematic investigation of the phase diagram of the iron-based superconductor Ba1-xKxFe2As2 from x = 0 to x = 1.0 using high-resolution neutron and x-ray diffraction and magnetization measurements. The polycrystalline samples were prepared with an estimated compositional variation of Delta x less than or similar to 0.01, allowing a more precise estimate of the phase boundaries than reported so far. At room temperature, Ba1-xKxFe2As2 crystallizes in a tetragonal structure with the space group symmetry of I4/mmm, but at low doping, the samples undergo a coincident first-order structural and magnetic phase transition to an orthorhombic (O) structure with the space group Fmmm and a striped antiferromagnet (AF) with the space group F(c)mm'm'. The transition temperature falls from a maximum of 139 K in the undoped compound to 0 K at x = 0.252, with a critical exponent as a function of doping of 0.25(2) and 0.12(1) for the structural and magnetic order parameters, respectively. The onset of superconductivity occurs at a critical concentration of x = 0.130(3), and the superconducting transition temperature grows linearly with x until it crosses the AF/O phase boundary. Below this concentration, there is microscopic phase coexistence of the AF/O and superconducting order parameters, although a slight suppression of the AF/O order is evidence that the phases are competing. At higher doping, superconductivity has a maximum T-c of 38 K at x = 0.4 that falls to 3 K at x = 1.0. We discuss reasons for the suppression of the spin density wave order and the electron-hole asymmetry in the phase diagram.