The pungent aroma of freshly brewed coffee swirls in the air, filling my nostrils as I cross the threshold of Caffè San Marco, one of Trieste's oldest cafés, where marble tables are supported by cast iron pedestals. Customers line the inlaid wooden counter, repeatedly stirring the sugar in their coffee as the spoons clink against their ceramic espresso cups. Voices are drowned by the gurgling, humming and whistling of the coffee machine that churns out one caffeine-infused beverage after another: caffè macchiato, espresso, cappuccino. The inhabitants of Trieste are said to imbibe twice as much coffee as elsewhere in Italy; statistics indicate the average Italian consumes 5.8kg of coffee a year, while in Trieste this is estimated to be 10kg.

Trieste's love for roasted beans can be traced back to the 18th century during 500 years of Habsburg rule, when Emperor Charles VI made the north-eastern city a free port. Trieste received beans from coffee plantations from around the world to supply coffee houses throughout the Austro-Hungarian Empire, most notably in Vienna, and it was here that some of the most important coffee trades in the Mediterranean were carried out. Coffee drinking became a popular pastime, and historic sites such as Caffè San Marco became the meeting point for intellectuals, writers and politicians to exchange ideas and stimulate their creativity. Irish novelist and poet James Joyce called the city his home for over 10 years – this is where he penned The Dubliners and A Portrait of the Artist as a Young Man. In the 19th century the city's cafes became a hotbed for the so-called irredentists, Italian nationalists who advocated the return to Italy of Italian-speaking districts including the Austrian lands of Trieste.

My guide Paola and I stroll Trieste's seafront, lined with pastel-coloured Neoclassical buildings that are a reminder of the city's Austro-Hungarian past. Empress Maria Theresa invested heavily in the city, constructing grand buildings, impressive piazzas and boulevards for the Habsburg Empire's only seaport. We walk past the shell-pink Old Stock Exchange Palace, with its Doric columns and early 19th-century gable clock. Between 1755 and 1844 these were the headquarters of international trade, crucial for the economic development of the city and the coffee trade.

We drive past the city's sprawling port that stretches out into the Adriatic. Strategically located mid-way between the Suez Canal and the straights of Gibraltar, the port of Trieste became the crossroads for ships arriving from the Indian Ocean and the Atlantic. More than two million coffee sacks are shipped here every year, of which a whopping 350,000 are delivered to the warehouse of Illy, the city's most renowned coffee brand. Founded by Francesco Illy in 1933, the coffee roasting company processes 100 tons of coffee every day. At its vast factory on the southern outskirts of the city, green beans are roasted and transformed into the much-prized Illy blend before being shipped all over the world.

Lining the Illy factory are neat and tidy rows of white and red flowers that echo the brand's signature colours. We are greeted by Moreno Faina, director of the University of Coffee. "Coffee?" he offers, as he ushers us past the reception area into the foyer. It would be rude not to. I sip my espresso at the bar with dozens of designer coffee cups swirling above in a modernist work of art.

Caffè San Marco (Alamy)

We tour the premises, where I learn that Illy produces a delicate, aromatic blend of nine different Arabica coffees. The building is home to advanced research labs and the University of Coffee aims to educate students about coffee culture and knowledge, from history to chemistry and biology (aficionados can embark on a master's degree in economics and coffee sciences).

We are escorted to the canister production department where machinery roars with energy, packaging ground coffee into pressurised recyclable cans that trap the coffee's aromas for about a year, or until they are opened.

Illy is undoubtedly Trieste's best-known brand, but the city is home to nearly a dozen independent torrefazioni, or micro-roasters. We later visit the much smaller Guatemala, run by a husband and wife team, which opened in 1980. At its coffee shop, assistants can tailor blends according to personal preferences. Trieste is one of the world's very few cities where to this day beans are roasted to order.

Statue of James Joyce on the habourside (Alamy)

We end our tour at the Caffè degli Specchi, in the heart of Trieste's grandiose Piazza Unità d'Italia. We sit at one of the tables that spill out onto the square, and I learn that Trieste even has its own coffee terminology: if you order a cappuccino you are served a caffè macchiato (an espresso with milk); you need to ask for a caffè latte (coffee with milk) instead. I sip my velvety coffee, marveling at how intricately linked the city's history is with coffee, the world's second most valuable commodity after oil.

GETTING THERE

Ryanair (0871 246 0000; ryanair.com) flies from Stansted to Trieste.

VISITING THERE

Illy University of Coffee (unicaffe.Illy.com) offers a half-day course with a factory tour for €475pp.

Caffe San Marco: caffesanmarcotrieste.eu

Caffè degli Specchi: caffespecchi.it

MORE INFORMATION