In 1971, Hahlweg was the SPD's first candidate for the office of Lord Mayor of Erlangen, losing out to Heinrich Lades with 48.1% of the votes. In the re-election, which became necessary one year later due to the territorial reform in Bavaria, he clearly won with 56.4% against Lades. At the age of 37, he was the youngest Lord Mayor of Bavaria when he took office. In the Mayor elections of 1978, 1984 and 1990 Hahlweg was confirmed in all cases in the first ballot. In the 1996 mayoral election, Hahlweg did not stand for re-election and resigned from office on 30 April 1996. Siegfried Balleis was elected as his successor.
Environmental policy
Dietmar Hahlweg's "conviction of the equivalence of ecology and economy" became a trademark of his politics. This led to an environmentally oriented urban development with environmentally friendlytransport policy and landscape and garden planning. Above all, the consistent promotion of utility cycling earned Erlangen the reputation of a bicycle city. But also other measures of Dietmar Hahlweg, such as the modernisation of the sewage treatment plant, the expansion of the district heating and natural gas networks and the direct feeding of solar power into the network of the municipal utilities, led to Erlangen's inclusion in the UN list of honour "Global 500" and to the award of the title "Federal Capital for Nature and Environmental Protection" by the Environmental Action Germany both in 1990 and 1991.
The Social Democrat Hahlweg also endeavoured to support Willy Brandt's Ostpolitik at local level. This included events such as "Encounter with Poland" or the start of negotiations on a town twinning with Vladimir in the then Soviet Union. The twinning negotiations led to success in 1987, as did the negotiations with Jena.
Dietmar Hahlweg has received numerous awards over the course of his life. In 1981 he was awarded the Nature Conservation Prize of the German Association for Nature Conservation in Bavaria. He has been a Knight of the French Legion of Honour since 1991 and was awarded the Federal Cross of Merit1st Class in 1993. Since 1995 he has been awarded the Bavarian Order of Merit. He is also honorary senator of the University of Erlangen–Nuremberg. Dietmar Hahlweg was awarded the honorary citizenship of Erlangen for his services to the city of Erlangen when he left office in 1996. In the same year he was awarded the Max & Moritz Prize at the Comic Salon Erlangen as a "special prize" of the jury. "It is thanks to this man, who doesn't even want to be called an explicit comic fan, that the Erlangen Comic Salon could become what it is today: a comic festival with world renown." Dietmar Hahlweg became nationally known through the Erlangen fun metal band J.B.O., because he is mentioned in their song Der Weiße Hai im Dechsendorfer Weiher.