Ellerman bombs (EBs) and UV bursts are both brightenings related to flux emergence regions and specifically to magnetic flux of opposite polarity that meet in the photosphere. These two reconnection-related phenomena, nominally formed far apart, occasionally occur in the same location and at the same time, thus challenging our understanding of reconnection and heating of the lower solar atmosphere. We consider the formation of an active region, including long fibrils and hot and dense coronal plasma. The emergence of a untwisted magnetic flux sheet, injected $2.5$~Mm below the photosphere, is studied as it pierces the photosphere and interacts with the preexisting ambient field. Specifically, we aim to study whether EBs and UV bursts are generated as a result of such flux emergence and examine their physical relationship. The Bifrost radiative magnetohydrodynamics code was used to model flux emerging into a model atmosphere that contained a fairly strong ambient field, constraining the emerging field to a limited volume wherein multiple reconnection events occur as the field breaks through the photosphere and expands into the outer atmosphere. Synthetic spectra of the different reconnection events were computed using the $1.5$D RH code and the fully 3D MULTI3D code. The formation of UV bursts and EBs at intensities and with line profiles that are highly reminiscent of observed spectra are understood to be a result of the reconnection of emerging flux with itself in a long-lasting current sheet that extends over several scale heights through the chromosphere. Synthetic diagnostics suggest that there are no compelling reasons to assume that UV bursts occur in the photosphere. Instead, EBs and UV bursts are occasionally formed at opposite ends of a long current sheet that resides in an extended bubble of cool gas.