LÜBECK, Germany — This city in the north is an architectural treasure trove, with soaring Gothic churches, ubiquitous crow-step gables, and quaint courtyards. It is listed among UNESCO’s World Heritage sites. Less than an hour from Hamburg, Lübeck also makes marzipan, a culinary treasure as important to the city’s identity as any of its architectural wonders.

Food lore explains that the confection was invented during a famine in 1407, when starving residents scoured the port city’s warehouses and found only almond remains and sugar. They turned the ingredients into almond meal, molded them into loaves, and distributed them to the needy on St. Mark’s Day. From this “Mark bread,” or Marci panis, came the word marzipan.

Omar Sacirbey for The Boston Globe

Coffee and confections are served at Cafe Niederegger.

In fact, marzipan, a mixture of ground almonds and sugar worked to a paste, was invented in Persia and brought to Europe by the Crusaders. In the Middle Ages, it was produced in monasteries and eaten during Lent. Marzipan was also thought to have healing properties, and for centuries only pharmacists were allowed to produce it. In the 18th century, Lübeck’s confectioners got approval to produce marzipan, but because sugar was so expensive, it was available to only a small portion of the population. That changed a century later, with the development of sugar refineries.

Advertisement

Today, marzipan is made in the Middle East and many European countries. In Lübeck, it is protected by European Union Law as a geographical indication of origin, like Gouda cheese or ham from Parma. That means a confection cannot be labeled “Lübeck marzipan” or “Lübeck Fine Marzipan” unless it meets certain standards, mainly relating to the balance of almond paste and sugar content (the “fine” has considerable more almonds than sugar).

Get The Weekender in your inbox:

The Globe's top picks for what to see and do each weekend, in Boston and beyond.

Lübeck’s most famous producer is Niederegger, whose store and cafe in the heart of town and across the street from the 13th-century Rathaus, the town hall, offers visitors a sweet and stylish respite from roaming the city’s historic streets.

Niederegger is a family-owned business that uses the same recipe founder Johann Georg Niederegger started with when he opened his confectionary in 1806. The fairy-tale-like shop is awash with colorful packages of marzipan and nougat confections, and dozens of shapes and figures: apples, bananas, castles, ducks, eels, flowers, hearts, loaves of roasted marzipan, chocolate-covered marzipan, marzipan coffee, marzipan liquor, and chocolate-covered marzipan bars, straight or infused with pistachio, mocha, pineapple, and other flavors.

Omar Sacirbey for The Boston Globe

Upstairs, a small museum features figures carved from marzipan.

There is also a long cake counter typically offering some 20 varieties. Among the most popular are Prince Heinrich, a biscuit base layered with brandy butter cream and nougat and topped with marzipan and walnut, and marzipan nut cake made with hazelnut cream covered with a layer of marzipan. You can eat them in the cafe, where coffee and cake are elevated to an art form.

With its burgundy chairs, gold chandeliers, decorative coffee pots, tall windows looking onto the always busy Breite Strasse, and baroque and classical music playing softly overhead, the cafe has an aristocratic air. In burgundy frocks, waitresses are prim but friendly. Customers range from white-haired ladies, men in suits, to students with nose rings. There is also a small but fun playroom to keep kids busy while their parents relax.

Advertisement

Upstairs, a small museum explains the history and science behind marzipan, displays some of the ancient tools, like a mortar and pestle used for grinding almonds, and a dozen life-size figures from the confection’s history, completely made from marzipan.

“It’s an important stop,” says Yuko Tada, who on a recent Saturday was buying marzipan for friends and family in Tokyo, and who already knew about Niederegger from German work colleagues. She buys marzipan as gifts, she says. Pigs and flowers are her favorites.

While Niederegger, which exports to 40 countries and employs around 500 people, is the best-known marzipan maker in Lübeck, there are others. Angela and Juergen Loehrke, visiting from Kiel, prefer Mest, whose small and simple shop is short walk from Niederegger. The difference is that Mest, founded in the 1950s and a family business with fewer than 20 employees, uses even less sugar than Niederegger for the almond paste. “It’s not so sweet, and it’s creamier and softer,” says Angela Loehrke.

For sweeter marzipan, head for the Marzipan Speicher, or Marzipan Warehouse, located on Lübeck’s west side along the picturesque Trave River. There, you will find marzipan in a wide variety of shapes and products, as well as a second-floor cafe where the feeling is less aristocratic and more novel.

Hanging on walls are pictures of old Lübeck and stills from the film adaptation of “The Buddenbrooks,” the novel by Lübeck-born Nobel laureate Thomas Mann, which was partly filmed in the shop.

Advertisement

Gaze at the boats resting on the river while savoring a rich marzipan cake.