Sea turtles inhabiting coastal environments routinely encounter anthropogenic hazards, including fisheries, vessel traffic, pollution, dredging, and drilling. To support mitigation of potential threats, it is important to understand fine-scale sea turtle behaviors in a variety of habitats. Recent advancements in autonomous underwater vehicles (AUVs) now make it possible to directly observe and study the subsurface behaviors and habitats of marine megafauna, including sea turtles. Here, we describe a "smart" AUV capability developed to study free-swimming marine animals, and demonstrate the utility of this technology in a pilot study investigating the behaviors and habitat of leatherback turtles (Dermochelys coriacea). We used a Remote Environmental Monitoring UnitS (REMUS-100) AUV, designated "TurtleCam," that was modified to locate, follow and film tagged turtles for up to 8 h while simultaneously collecting environmental data. The TurtleCam system consists of a 100-m depth rated vehicle outfitted with a circular Ultra-Short BaseLine receiver array for omni-directional tracking of a tagged animal via a custom transponder tag that we attached to the turtle with two suction cups. The AUV collects video with six high-definition cameras (five mounted in the vehicle nose and one mounted aft) and we added a camera to the animal-borne transponder tag to record behavior from the turtle's perspective. Since behavior is likely a response to habitat factors, we collected concurrent in situ oceanographic data (bathymetry, temperature, salinity, chlorophyll-a, turbidity, currents) along the turtle's track. We tested the TurtleCam system during 2016 and 2017 in a densely populated coastal region off Cape Cod, Massachusetts, USA, where foraging leatherbacks overlap with fixed fishing gear and concentrated commercial and recreational vessel traffic. Here we present example data from one leatherback turtle to demonstrate the utility of TurtleCam. The concurrent video, localization, depth and environmental data allowed us to characterize leatherback diving behavior, foraging ecology, and habitat use, and to assess how turtle behavior mediates risk to impacts from anthropogenic activities. Our study demonstrates that an AUV can successfully track and image leatherback turtles feeding in a coastal environment, resulting in novel observations of three-dimensional subsurface behaviors and habitat use, with implications for sea turtle management and conservation.