The interior structure of Saturn, the depth of its winds and the mass and age of its rings constrain its formation and evolution. In the final phase of the Cassini mission, the spacecraft dived between the planet and the innermost ring, at altitudes 2600-3900 km above the cloud tops. During six of these crossings, a radio link with Earth was monitored to determine the gravitational field of the planet and the mass of its rings. We find that Saturn’s gravity deviates from theoretical expectations and requires differential rotation of the atmosphere extending to a depth of at least 9000 km. The total mass of the rings is (1.54 ± 0.49)×1019 kg (0.41 ± 0.13 times that of the moon Mimas), indicating that the rings may have formed 107-108 years ago.