This picture-perfect medieval city is celebrating its 900th anniversary, but its innovative design makes it one of the world’s most sustainable and liveable cities.

“900 years young” reads the bold slogan emblazoned on the side of the tram as it rattles through Freiburg im Breisgau’s historical Old Town. Celebrating its 900th anniversary since originating as a merchant settlement in 1120, the medieval German city nestled at the foot of the Black Forest near the border triangle of Switzerland, France and Germany is arguably quite old.

It does, however, have youth on its side. Around 10% of the city’s 220,000 residents attend the prestigious Albert Ludwig University, making the population one of Germany’s youngest. Mayor Martin Horn was just shy of 34 when he was inaugurated at Town Hall in 2018. And the colourful half-timbered houses and car-free cobblestone streets lining its Old Town are, in fact, relatively young, as they were faithfully reconstructed after World War Two bombings. These ingredients have all helped create a Freiburg that is one of Germany’s, if not the world’s, most liveable, progressive, sustainable and child-friendly cities. So, while the city reflects on its 900-year history, I’m here to find out what makes it a city of the future.

For most, the city’s sustainable turning point can be traced back to February 1975. Thousands of protestors camped out for nine months on a patch of land 30km north of Freiburg deep in the Black Forest. “The protest was peaceful at the time, deeply rooted in solidarity,” said Axel Mayer, who took part in the event and is now the managing director of BUND (Federation for Environment and Nature Protection Germany). Though spearheaded by locals, the eclectic group of protesters grew to include left-wing activists, Alsatian winegrowers, skiers, German farmers, architects, doctors, educators, journalists, orchestral musicians and police officers, all united in their mission to stop construction of the proposed Wyhl nuclear power plant.

As the trucks rolled out nine months later, with construction permanently halted, this successful exemplar of citizen-led activism led Freiburg to become a breeding ground for alternative thinking and birthed a green movement. In the decades since, Freiburg has quickly developed as an environmental economics and solar research hub with a packed green CV:

• 1994: Builds Heliotrope: the world‘s first energy-plus house

• 2002: Elects Germany’s first Green Party mayor, Dieter Salomon

• 2002: Wins Dubai International Best Practices award for sustainable development

• 2010: Wins national award for its climate protection efforts

• 2012: Named most sustainable city in Germany

• 2017: New Town Hall becomes world’s first public building producing surplus energy

Last year, Freiburg invited some 25,000 officials and urban planners from around the world to learn from these ground-breaking projects. Thanks to this sharing of knowledge, Padua, a sister city in northern Italy, has since installed Italy’s largest solar farm; while Madison in the US state of Wisconsin is currently planning the construction of a Sustainability Centre based on the Solar Centre in Freiburg.

Many of these visitors were shown around by my guide for the day, Andrea Philipp from the sustainability agency Aiforia. “We were running so many tours, sometimes four a day,” she told me. “We had to promise locals we wouldn’t run tours on Sundays anymore to give them a break.”

With 400km of bike paths and twice as many bikes as cars, Freiburg is a cyclists’ paradise

We were at the Freiburg bike station, an imposing cylindrical building just behind the main train station.

“I don’t own a car, and I don’t need one. You can cycle everywhere in Freiburg,” Philipp added, as I unlocked my rental bike. With 400km of bike paths and twice as many bikes as cars, Freiburg is a cyclists’ paradise.

This intentional design can be traced back to the post-war period. While other German cities were focusing on rebuilding modern cities that put cars at the centre of future transport, planners in Freiburg took a different approach, centring their designs around public transport, thus widening the streets to accommodate trams and bike lanes, including large pedestrian zones. And at a time when much of Germany was building wide highways and sprawling car parks, Freiburg launched its first urban transport policy in 1969 focusing on environmentally-friendly modes of travel.

After consulting the free Green City map showing all of the city’s green initiatives, we began our tour, crossing the iconic blue Wiwilíbrücke bridge and heading towards the Farmers Market in Cathedral Square. In the shadows of the 13th-Century gothic tower, every morning (bar Sunday) the square bustles with local produce from 96 stallholders from the region. Much of the produce on offer is organic, owing to the city’s membership in Germany’s Bio-Städte collective that promotes organic farming.

Growing up in Freiburg means that wherever you are, you see the mountains with the forest

After sampling a 35cm Lange Rote (Long Red) sausage, the city’s favourite edible emblem, we left the Old Town along the FR1, a dedicated bike highway that carries the 15,000 cyclists who travel daily along its 10km route. As we rode alongside the fast-flowing Dreisam River, Philipp told me about a renaturation project that’s designed to be an environmental tit-for-tat to compensate for the nearby train line expansion. “They’re letting the river overflow on the right-hand side to double its size, and welcoming back birds and insects,” she said.

You may also be interested in:
What makes Germans so orderly?
Is Gothenburg Europe's greenest city?
Germany's tiny geographic oddity

On match days, a sea of football fans travel along the FR1 and descend on the 24,000-seat Schwarzwald-Stadion, Germany’s first solar-powered football stadium that’s home to local heroes SC Freiburg. Since solar panels were fitted to the grandstand roofs in 1993, the stadium has generated 250,000 kilowatt-hours per year, powering the stadium and feeding any excess back into the local grid. Borrowing this design ethos is the much-anticipated new Freiburg Stadium, which is integrating solar panels onto its roof and recycling energy generated from a nearby manufacturing plant to heat the stadium. Boasting 10,000 additional seats, it’s on track to host its first match by the end of 2020.

For locals looking for more earthly pursuits, the surrounding Black Forest provides a welcome refuge. The vast mountain range hosts walking tracks, community gardens, allotment gardens, BMX runs and tiny forest cabins belonging to kindergartens. Freiburg native Konstantin Hoffmann remembers his childhood with this connection to nature fondly.

“Growing up in Freiburg means that wherever you are, you see the mountains with the forest,” he said. “When I was a child, the kindergarten often took us into the nearest forest. I would say because I had such an early binding to nature, the environment and sustainability is deeply rooted in my thoughts.”

Lying just 3km from the city centre, the much-celebrated planned suburban community of Vauban, has a similar environmentally conscious ethos at its heart. Here, civic involvement goes hand in hand with “collective building” – where citizens buy a piece of land together and build an apartment building themselves, instead of individually buying an apartment from a development company – and ambitious environmental policy. Basically, “people are more green, more alternative and more social,” Hoffmann said.

Vauban's 5,500 residents live in close-knit cooperatives, private households or social housing developments that cover the suburb's 40 hectares. All housing adheres to Freiburg’s low-energy building standard of 65 kWh/sq m, and the minimal energy that is brought in is generated locally from the wood-chip powered heating systems located in the neighbourhood.

Between the rooftop gardens, food-sharing pantries, organic waste anaerobic digesters, conflict-resolution workshops and co-op supermarkets, it’s impossible to list every social project the community runs, so instead Philipp told me about the one thing it doesn’t have: cars.

In Vauban, car ownership sits at around 172 cars per 1,000 residents, compared to 393 in greater Freiburg and 531 in the nearby industrial metropolis of Stuttgart. Many of the streets where you’d expect to see cars parked have been reimagined as playground cul-de-sacs for kids. Apparently, owning a car is the easiest way to commit social suicide in Vauban. “There are occasionally problems between neighbours if someone parks their car in the pick-up area for too long or doesn’t declare they own a car,” Philipp said. Others take it a step further, hiding their cars in neighbouring towns to avoid the accusatory glares.

Across town, 50 Bugginger Strasse is the address of one of the city’s most ambitious rejuvenation projects. The 16-storey high-rise looming overhead appears unremarkable, with its mixture of green- and aqua-panelled external balconies the only eye-catching elements. But Philipp explains that this is, in fact, the world's first passive energy high-rise, in which heat is produced from internal appliances, body heat, and things like lightbulbs rather than conventional heating systems.

Ten years ago, urban planners Stadtbau embarked on a massive redevelopment project that saw the original 90 apartments redesigned to accommodate 139 dwellings to combat Freiburg’s housing shortage. Through energy-saving lighting and lifts, solar panels, triple-glazed windows and a new passive exhaust heat system housed in the attic, they achieved a 78% reduction in energy use, bringing the 1968 Brutalist building inline with the city's aggressive standards. Social cohesion has even been considered. “If someone moves out, residents on each floor get to vote on who they want to move in. So, if you don’t want a neighbour who plays the guitar, you can say no,” laughed Philipp.

Two kilometres east, there is perhaps no greater proof of municipal commitment to sustainability than the new Town Hall. Inside, it’s light and bright, looking more like the spacious atrium of a modern shopping mall than a government office. Its exterior is clad with 4,000 sq m of solar modules, giving it the honour of the world’s first public plus-energy building – meaning it produces more energy than it needs and feeds the excess back into the city’s electric grid – when it opened in 2017. Conceived under the 16-year leadership of the former green mayor Dieter Salomon, the building’s solar panels produced 560 megawatt hours of electricity in its first year – equal to the annual usage of 140 four-person households.

So, what does the future hold for a city already pushing the envelope? This Benjamin Button-esque city recorded more births than new arrivals last year, so it will continue to get younger as it ages. And with renewed targets at 50% less CO2 emissions by 2030 and 100% energy from renewable sources by 2050, Freiburg is continuing confidently towards an even greener tomorrow.

Comeback Cities is a BBC Travel series that showcases under-the-radar capitals, champions the urban underdogs and revels in the success stories of cities that have turned their fortunes around.

Join more than three million BBC Travel fans by liking us on Facebook, or follow us on Twitter and Instagram.

If you liked this story, sign up for the weekly bbc.com features newsletter called "The Essential List". A handpicked selection of stories from BBC Future, Culture, Worklife and Travel, delivered to your inbox every Friday.