  We report on the detection of flaring activity from the Fanaroff-Riley I
radio galaxy NGC 1275 in very-high-energy (VHE, E $>$ 100 GeV) gamma rays with
the MAGIC telescopes. Observations were performed between 2016 September and
2017 February as part of a monitoring program. The brightest outburst with
$\sim1.5$ times the Crab Nebula flux above 100 GeV (C.U.) was observed during
the night between 2016 December 31 and 2017 January 1 (fifty times higher than
the mean previously measured in two observational campaigns between 2009 and
2011). Significant variability of the day-by-day light curve was measured, the
shortest flux-doubling time-scales was found to be of $(611\pm101)$ min. The
combined spectrum of the MAGIC data during the strongest flare state and
simultaneous data from the Fermi-LAT around 2017 January 1 follows a power-law
with an exponential cutoff at the energy $(492\pm35)$ GeV. Simultaneous optical
flux density measurements in the R-band obtained with the KVA telescope are
also presented and the correlation between the optical and gamma-ray emission
is investigated. Due to possible internal pair-production, the fast flux
variability constrains the Doppler factor to values which are inconsistent with
a large viewing angle as observed in the radio band. We investigate different
scenarios for the explanation of fast gamma-ray variability, namely emission
from: magnetospheric gaps, relativistic blobs propagating in the jet
(mini-jets) or external cloud (or star) entering the jet. We find that the only
plausible model to account for the luminosities here observed would be the
production of gamma rays in a magnetospheric gap around the central black hole
only in the eventuality of an enhancement of the magnetic field threading the
hole from its equipartition value with the gas pressure in the accretion flow.
