The three-dimensional breakup of a magnetic layer