  The first measurements of dielectron production at midrapidity
($|\eta_{c}|<0.8$) in proton-proton and proton-lead collisions at
$\sqrt{s_{\rm{NN}}}$ = 5.02 TeV at the LHC are presented. The dielectron cross
section is measured with the ALICE detector as a function of the invariant mass
$m_{\rm{ee}}$ and the pair transverse momentum $p_{\rm{T,ee}}$ in the ranges
$m_{\rm{ee}}$ < 3.5 GeV/$c^{2}$ and $p_{\rm{T,ee}}$ < 8.0 GeV/$c^{2}$, in both
collision systems. In proton-proton collisions, the charm and beauty cross
sections are determined at midrapidity from a fit to the data with two
different event generators. This complements the existing dielectron
measurements performed at $\sqrt{s}$ = 7 and 13 TeV. The slope of the
$\sqrt{s}$ dependence of the three measurements is described by FONLL
calculations. The dielectron cross section measured in proton-lead collisions
is in agreement, within the current precision, with the expected dielectron
production without any nuclear matter effects for $\rm{e}^{+}\rm{e}^{-}$ pairs
from open heavy-flavor hadron decays. For the first time at LHC energies, the
dielectron production in proton-lead and proton-proton collisions are directly
compared at the same $\sqrt{s_{\rm{NN}}}$ via the dielectron nuclear
modification factor $R_{\rm{pPb}}$. The measurements are compared to model
calculations including cold nuclear matter effects, or additional sources of
dielectrons from thermal radiation.
