Something we take for granted in our criminal justice system is the existence of jails and prisons. They're one of the staples of punishment used for people who commit crimes. You don't want a criminal on the streets, but the death penalty just seems far too harsh, so... lock them up for a period of time where you can safely watch them.
They're not exactly ancient, though. Jails have existed for a good long while, but for most of history, they were simply used as a place to keep the prisoner while they prepared his real punishment, be it beatings, mutilation or death. The jail was not the punishment in and of itself. The Tower of London was built in the 11th century, but it was a holding area.
The problem is that there are several candidates to the title of 'first true prison', as there hasn't been a clear titleholder. It's not exactly a title worth crowing about. There's the Gevangenpoort in the Hague, from the 15th century. There's Eastern State Penitentiary in Philadelphia, opening in 1829. The London system in general is a claimant in the 19th century. As far as a widespread thing, London and Eastern State fall more in line with the real popularity of the system.
Beating all of them, though, as far as I can find, is what is now Border History Museum in Hexham, Northumberland. Their jail- or gaol in local terminology- was constructed in 1330. The diagram can be seen here on the museum's website.
It was really an accidental punishment, as they intended it as a holding place as well, but since trials were only held once every three months, jail became a de facto punishment in and of itself, especially as once the trials got underway, the harsh nature of the intended punishments- the death penalty was common- caused many juries to declare defendants not guilty simply because the punishment didn't fit the crime.
If someone was held in the dungeon, though, they got punishment enough.
For the dungeon was infested with rats. In a prison that opened a mere 18 years before the Black Plague began.