The present study aims at investigating unsteady hydromagnetic flow of viscous incompressible, conducting nanofluid over an infinite oscillating surface with Joule heating. The governing equations involved are transformed into dimensionless form using appropriate non-dimensional variables. The resulting dimensionless momentum equation is solved analytically by using the method of separation of variables. The Joule heating terms in the energy equation are expressed explicitly using this solution. With the help of the superposition principle, a complementary function is creatively synthesized and a particular integral is obtained by the method of undetermined coefficients. The complete solution is obtained by summing the two. The effects of magnetic field strength, oscillation frequency, nanoparticle concentration, Prandtl number and the Eckert number are illustrated graphically.