SEDRUN, Switzerland — Workers hugged, cheered and set off fireworks as a massive drilling machine dubbed “Sissi” broke through the last stretch of rock deep in the Swiss Alps. There was delight at the end of the tunnel — the world’s longest — when it was completed Friday.

The $10 billion, 35.4-mile tube will connect Europe’s high-speed-rail network and is part of a larger effort to cut in half the number of trucks — now 1.2 million — that thunder through the Alps each year.

The pride felt throughout Switzerland over digging the Gotthard Base Tunnel reflected the one cause that unites the country’s wealthy city dwellers with those living in traditional villages: Protecting the beauty of the mountains.

“Together, we risked a lot,” said Swiss Transport Minister Moritz Leuenberger. “Together, we achieved a lot.”

TV stations across Europe showed the event live. The embraces and cheers by the hard-hatted workers brought to mind the successful rescue of 33 miners this week in Chile.

Swiss voters approved the tunnel’s construction in a series of referendums almost 20 years ago.

The new tunnel, conceived in 1947 by engineer Eduard Gruner, will allow millions of tons of goods that are currently transported through the Alps on heavy trucks to be shifted onto the rails, particularly on the economically important link between the Dutch port of Rotterdam and Italy’s Mediterranean port of Genoa.

The tunnel also aims to reduce the damage that heavy trucks are inflicting on Switzerland’s pristine Alpine landscape.

Some 2,500 workers spent nearly 20 years smashing through the rock beneath the towering Gotthard massif, including the 8,200-foot Vatgira Peak.

When the tunnel opens for rail traffic in 2017, it will replace Japan’s 33.5-mile Seikan Tunnel as the world’s longest — excluding aqueducts — and let passenger and cargo trains pass under the Alps at speeds of up to 167 mph on their way from Germany to Italy.

Experts estimate that the tunnel will cut the 3.5-hour travel time from Zurich to Milan, Italy, by an hour and from Zurich to Lugano to one hour, 40 minutes.

When completed, the Gotthard tunnel will form part of a larger trans-Alpine rail system, which includes the Loetschberg base tunnel and, later this decade, is set to be joined by the planned Brenner and Mont Cenis base tunnels.

Swiss engineers are hoping to complete the rail tunnel even sooner than planned — possibly by the end of 2016 — but its first high-speed trains could be delayed by protests in Germany and Italy, where opposition to new tracks and budget constraints have become an issue recently.

The amount of rock that was excavated to build the tunnel was equivalent to more than five times the volume of Egypt’s Great Pyramid of Giza, engineers said.