itself with a wall and hold markets. The wall was built by Count Ulrich III of Abensberg. Some of the thirty-two round towers and eight turrets are still preserved to this day. In the Middle Ages, the people of Abensberg enjoyed a level of autonomy above their lord. They elected a city council, although only a small number of rich families were eligible for election. In around 1390, the Carmelite Monastery of Our Lady of Abensberg was founded by Count John II and his wife, Agnes. Although Abensberg was an autonomous city, it remained dependent on the powerful Dukes of Bavaria. The last Lord of Abensberg, Niclas, Graf von Abensberg, supposedly named after his godfather, Nicholas of Kues, a Catholic cardinal, was murdered in 1485 by Christopher, a Duke of Bavaria-Munich. The year before, Niclas had unchivalrously taken Christopher captive as he bathed before a tournament in Munich. Although Christopher renounced his claim for revenge, he lay in wait for Niclas in Freising. When the latter arrived, he was killed by Seitz von Frauenberg. He is buried in the former convent of Abensberg. Abensberg then lost its independence and became a part of the Duchy of Bavaria, and from then on was administered by a ducal official, the so-called caretaker. The castle of Abensberg was destroyed during the Thirty Years' War, although the city had bought a guarantee of protection from the Swedish general, Carl Gustaf Wrangel. During the War of the Spanish Succession emperor Leopold I, who had occupied Bavaria, granted the fief of Abensberg to count Ernst von Abensperg und Traun (1608–1668) from an Austrian noble family named Traun that now received the name of the former counts of Abensberg (who were believed to be distant relatives). After the occupation ended, he was however dispossessed. Johannes Aventinus (1477–1534) is the city's most famous son, the founder of the study of history in Bavaria. Aventinus, whose name was real name is Johann or Johannes Turmair (Aventinus being the Latin name of his birthplace) wrote the Annals of Bavaria, a valuable record of the early history of Germany and the first major written work on the subject. He is commemorated in the Walhalla temple, a monument near Regensburg to the distinguished figures of German history. Until 1800, Abensberg was a municipality belonging to the Straubing district of the Electorate of Bavaria. Abensberg also contained a magistrates' court. In the Battle