The world’s first underground railway opened in 1863 in London. The Metropolitan Railway began public service on 10 January 1863, linking Paddington with Farringdon through the northern part of central London.
The railway was built largely by the cut-and-cover method: workers excavated a trench, constructed the tracks and brick tunnel, then covered it again. Its trains used steam locomotives and gas-lit wooden carriages, creating smoky conditions underground. Despite that discomfort, the line carried about 38,000 passengers on its opening day.
The Metropolitan Railway was created to connect London’s mainline railway termini with the City, the capital’s financial centre. Its success encouraged other underground lines and helped shape the network now known as the London Underground. The modern Metropolitan line retains the name, although much of its route is above ground.
The 1863 railway was the first designated underground passenger railway, not the first railway ever built in a tunnel. That distinction is why London is the canonical answer to this question.