The oldest snake remains (Eophis underwoodi) so far is 167 million years old. Its length could reach 25 cm, and it could live in a swampy environment. The first snakes were shorter than that of today. The recorder is the Jurassic (155 million years old) Portugalophis lignites with a length of 1.2 m. This snake, which was considered huge in the prehistoric world fed on small mammals and birds, but it could consume young dinosaurs as well.
These snakes had vestigial fore and hind limbs, which they used for grasping rather than moving. As their body became elongated, first their redundant fore limbs disappeared, and then they lost their hind limbs.
Snakes are closely related to Mosasaurs, but it is unclear whether they came from marine or dryland ancestors.

Fossil of the Tetrapodophis amplectus, a snake with four limbs. Photo by Philip Bell, 2015

Reconstruction drawing of Diablophis gilmorei, which is from the Morrison Formation in Colorado. It lived 155 mya. Its length was probably 30 xm, and it has legs. Drawing by Julius T. Csotonyi, 2014

Photo A shows the forelimbs of Tetrapodophis amplectus, and photo C shows its hind limbs and its pelvis. Photos by David M. Martill et al., 2015

Interesting fossil assemblage from the 65 milion years olda sediments of the West Indian Gujarat, which gives insight into the feeding habits of prehistoric snakes. The remains of the 3.5 m long Sanajeh hindicus were discovered in a Sauropod nest near a newborn dinosaur. Photo by Jeffrey A. Wilson et al., 2010