This paper presents the new exact analytical solutions for magnetohydrodynamic (MHD) flows of an Oldroyd-B fluid. The explicit expressions for the velocity field and the associated tangential stress are established by using the Laplace transform method. Three characteristic examples: (i) flow due to impulsive motion of plate, (ii) flow due to uniformly accelerated plate, and (iii) flow due to non-uniformly accelerated plate are considered. The solutions for the hydrodynamic flows are special cases of the presented solutions. Moreover, the similar solutions corresponding to Maxwell and Newtonian fluids in the presence as well as absence of a magnetic field appear as the limiting cases of our solutions. The influences of the exerted magnetic field on the flow are also graphically presented and discussed. In particular, graphical results for the Oldroyd-B fluid are compared with those of a Newtonian fluid.