In his book on Electrodynamics (Lectures on Theoretical Physics, Vol. 3), Chapter 32-E, Arnold Sommerfeld talks about "Schwarzschild's principle of least action", developed by K. Schwarzschild (Göttinger Nachrichten 1903, English translation here). Recall that the action is just the space-time integral of the Lagrangian density. The principle of least action then varies the action to arrive at the Euler-Lagrange equations. For Schwarzschild's action these are indeed Maxwell's equations and the Lorentz force equation. In a footnote, Sommerfeld says admiringly:
Note the publication date of 1903! Thus Schwarzschild arrived intuitively at the correct postulate of the theory of invariants six years ahead of Minkowski.
Of course, Schwarzschild's Lagrangian also predates Einstein's special relativity by two years. It is indeed remarkable that Schwarzschild obtained the correct Lorentz invariant Lagrangian of electromagnetism at such an early stage.
Schwarzschild himself refers to Lorentz (I believe to this paper from 1892) and Helmholtz (presumably this publication of the same year). Both authors have formulated somewhat clumsy and incomplete precursors to Schwarzschild's (basically) modern version.