It was proven by Ronald Fagin in 1974. The arity required by the second-order formula was improved (in one direction) in Lynch's theorem, and several results of Grandjean have provided tighter bounds on nondeterministic random-access machines.
Immerman 1999 provides a detailed proof of the theorem. Essentially, we use second-order existential quantifiers to guess a computation tableau. For every timestep, we guess the finite state control's state, the contents of every tape cell, and which nondeterministic choice we must make. Verifying that each timestep follows from each previous timestep can then be done with a first-order formula.