Surface-associated bacterial communities flourish in nature and in the body of animal hosts with abundant macromolecular polymers. It is unclear how the endowed viscoelasticity of polymeric fluids influences bacterial motile behavior in such environments. Here, we combined experiment and theory to study near-surface swimming of flagellated bacteria in viscoelastic polymer fluids. In contrast to the swimming behavior in Newtonian fluids, we discovered that cells swim in less curved trajectories and display reduced near-surface accumulation. Using a theoretical analysis of the non-Newtonian hydrodynamic forces, we demonstrated the existence of a generic lift force acting on a rotating filament near a rigid surface, which arises from the elastic tension generated along curved flow streamlines. This viscoelastic lift force weakens the hydrodynamic interaction between flagellated swimmers and solid surfaces and contributes to a decrease in surface accumulation. Our findings reveal previously unrecognized facets of bacterial transport and surface exploration in polymer-rich environments that are pertinent to diverse microbial processes and may inform the design of artificial microswimmers capable of navigating through complex geometries.