We report the synthesis of superconducting MgB2 thin films grown in situ by molecular-beam epitaxy. Mg-rich fluxes are deposited with B flux by electron-beam evaporation onto c-plane sapphire substrates. The films exhibit c-axis oriented peaks of MgB2, and a full width at half maximum of 3° in their rocking curves. In-plane alignment of MgB2 shows 12-fold symmetry, which is observed by the selected area diffraction pattern in transmission electron microscopy. The MgB2 films show a superconducting transition at 34.5 K with ΔTc<1 K. Even though the residual resistivity of the films is quite high (∼60 μcm), the normal-state resistivity has a very similar temperature dependence but is five times larger than that of a single crystal, implying that conduction through the whole sample is imperfectly connected or inhomogeneous. Upper critical fields are obtained from measurement of the field dependence of the resistivity. It is estimated that the upper critical field at 20 K is more than 15 T, which is one of the largest values ever reported.