  The SNR G106.3+2.7, detected at 1--100 TeV energies by different $\gamma$-ray
facilities, is one of the most promising PeVatron candidates. This SNR has a
cometary shape which can be divided into a head and a tail region with
different physical conditions. However, it is not identified in which region
the 100 TeV emission is produced due to the limited position accuracy and/or
angular resolution of existing observational data. Additionally, it remains
unclear whether the origin of the $\gamma$-ray emission is leptonic or
hadronic. With the better angular resolution provided by these new MAGIC data
compared to earlier $\gamma$-ray datasets, we aim to reveal the acceleration
site of PeV particles and the emission mechanism by resolving the SNR
G106.3+2.7 with 0.1$^\circ$ resolution at TeV energies. We detected extended
$\gamma$-ray emission spatially coincident with the radio continuum emission at
the head and tail of SNR G106.3+2.7. The fact that we detected a significant
$\gamma$-ray emission with energies above 6.0 TeV from the tail region only
suggests that the emissions above 10 TeV, detected with air shower experiments
(Milagro, HAWC, Tibet AS$\gamma$ and LHAASO), are emitted only from the SNR
tail. Under this assumption, the multi-wavelength spectrum of the head region
can be explained with either hadronic or leptonic models, while the leptonic
model for the tail region is in contradiction with the emission above 10 TeV
and X-rays. In contrast, the hadronic model could reproduce the observed
spectrum at the tail by assuming a proton spectrum with a cutoff energy of
$\sim 1$ PeV for the tail region. Such a high energy emission in this
middle-aged SNR (4--10 kyr) can be explained by considering the scenario that
protons escaping from the SNR in the past interact with surrounding dense gases
at present.
