Detection of very-high energy gamma-ray emission from NGC 1275 by the MAGIC telescopes