The paper provides an analytical investigation, homotopy analysis method (HAM), of the heat and mass transfer for magnetohydrodynamic Oldroyd-B nanofluid flow over a stretching sheet in the presence of convective boundary condition. The PDE governing equations, which consist of equations of continuity, momentum, energy and nanoparticles, are converted to ordinary differential equations using similarity transformations. The current HAM solution demonstrates very good correlation with those of the previously published studies in the special cases. The influences of different flow physical parameters such as the Deborah numbers in terms of relaxation and retardation times ([Formula: see text], [Formula: see text]), magnetic parameter (M), Prandtl number (Pr), Brownian motion parameter (Nb), thermophoresis parameter (Nt), Lewis number (Le), and Biot number (Bi) on the fluid velocity component [Formula: see text], temperature distribution [Formula: see text] and concentration [Formula: see text] as well as the local Nusselt number [Formula: see text] and the local Sherwood number [Formula: see text] are discussed in detail.