Épernon was originally the home of the counts of Montfort and Amaury. In the 11th century, they raised the fortresses of Épernon and Montfort for the protection of the Château de St Léger and granted a charter to the town. Four gates gave access to the medieval city: the gate of Chartres, the gate of Geolle, the gate of Paris and the gate of Beauce. Above the gates an inscription paid homage to the village that previously existed there: Autrist fut jadis mon nom/A présent on me nomme Espierremont (Autrist was once my name/now my name is Espierremont). Charters of the 12th and 13th century variously refer to the town as Sparno and Sparnonum, but by the 14th century it had evolved to Esparnon and Espernon, very close to its present appellation.
In the 13th century it became an independent lordship, which remained attached to the crown of Navarre till, in the 16th century, it was sold by Henry III of France to Jean Louis de Nogaret de La Valette, for whom it was raised to the rank of a duchy in 1581. De Nogaret's second son, Bernard (1592–1661), succeeded his father to the dukedom and after his death, the title was borne by the families of Goth and of Pardaillan.
The Marquis de Sade was buried in an unmarked grave on his family property in Épernon.