Context. Certain types of supernova remnants (SNRs) in our Galaxy are assumed to be PeVatrons, capable of accelerating cosmic rays (CRs) to ∼ PeV energies. However, conclusive observational evidence for this has not yet been found. The SNR G106.3+2.7, detected at 1-100 TeV energies by different γ-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, in which region the 100 TeV emission is produced has not yet been identified because of the limited position accuracy and/or angular resolution of existing observational data. Additionally, it remains unclear as to whether the origin of the γ-ray emission is leptonic or hadronic. Aims. With the better angular resolution provided by new MAGIC data compared to earlier γ-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 • resolution at TeV energies. Methods. We observed the SNR G106.3+2.7 using the MAGIC telescopes for 121.7 hours in total -after quality cuts-between May 2017 and August 2019. The analysis energy threshold is ∼ 0.2 TeV, and the angular resolution is 0.07-0.1 • . We examined the γ-ray spectra of different parts of the emission, whilst benefitting from the unprecedented statistics and angular resolution at these energies provided by our new data. We also used measurements at other wavelengths such as radio, X-rays, GeV γ-rays, and 10 TeV γ-rays to model the emission mechanism precisely. Results. We detect extended γ-ray emission spatially coincident with the radio continuum emission at the head and tail of SNR G106.3+2.7. The fact that we detect a significant γ-ray emission with energies above 6.0 TeV from only the tail region suggests that the emissions above 10 TeV detected with air shower experiments (Milagro, HAWC, Tibet ASγ 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 ∼ 1 PeV for that region. Such high-energy emission in this middle-aged SNR (4-10 kyr) can be explained by considering a scenario where protons escaping from the SNR in the past interact with surrounding dense gases at present. Conclusions. The γ-ray emission region detected with the MAGIC telescopes in the SNR G106.3+2.7 is extended and spatially coincident with the radio continuum morphology. The multi-wavelength spectrum of the emission from the tail region suggests proton acceleration up to ∼ PeV, while the emission mechanism of the head region could either be hadronic or leptonic.