It was a nil wind day, I had given the engine a thorough runup and there was nothing suspicious detected. We had just taken off and at about 100' the engine coughed. At 250' it coughed again, and then one of the magneto's failed. The engine cowling started vibrating quite badly so I smoothly reduced power and the shaking stopped at about 75% throttle. Even on one mag and partial throttle the plane was still climbing so I chose to return to the field instead of landing ahead. Had the engine quit at any time during the reversal turn I was well within gliding distance of a runway (thank goodness I was in a 172M and not the Arrow) and in the end I circled and put her down on a crossing runway.
I realize I didn't exactly do things by the book, so please, follow the advice of the vastly more experienced pilots and instructors lurking around rather than me.