We present an analysis of mixed convection boundary layer flow of an incompressible and electrically conducting viscoelastic fluid over a linearly stretching surface embedded in a porous medium. The momentum equation includes the effect of the buoyancy force due to free convection. The thermal equation includes the effects of thermal radiation and viscous dissipation. We consider two general types of nonisothermal boundary conditions, namely, prescribed surface temperature and prescribed heat flux. The governing partial differential equations for the fluid flow and temperature are reduced to a nonlinear system of ordinary differential equations which are solved analytically using the homotopy analysis method (HAM). Convergence of the HAM solutions is discussed in detail. The effects of various parameters on the skin friction coefficient and wall heat transfer are presented along with plots of the velocity and temperature profiles.