We perform first-principles relativistic particle-in-cell simulations of aligned pulsar magnetosphere. We allow free escape of particles from the surface of a neutron star and continuously populate the magnetosphere with neutral pair plasma to imitate pair production. As pair plasma supply increases, we observe the transition from a charge-separated electrosphere solution with trapped plasma and no spin-down to a solution close to the ideal force-free magnetosphere with electromagnetically-dominated pulsar wind. We calculate the magnetospheric structure, current distribution and spin-down power of the neutron star. We also discuss particle acceleration in the equatorial current sheet.