The Haramain High Speed Rail system will transport Muslim pilgrims, as well as regular travellers, 450 kilometres (280 miles) between the two cities via the Red Sea port of Jeddah in two hours.
“This project is considered the biggest transport project in the Middle East,” Mohammed Falaha, a Haramain project manager, said.
Thirty-five passenger trains capable of travelling at speeds of 300 kilometres per hour will slash the travel time from several hours to 120 minutes, transport officials said.
The rail project, dogged by several delays, was built at a cost of more than $16 billion, according to Saudi media.
In 2011, Saudi Arabia signed a deal for a Spanish consortium to build the rail track, supply 35 high-speed trains and handle a 12-year maintenance contract.
The kingdom is boosting its infrastructure spending and expanding its railways, including with a $22.5 billion metro system under construction in the capital Riyadh, as it seeks to diversify its oil-dependent economy.
The annual Haj pilgrimage, which is to be held in September next year, attracts more than two million Muslims to the Makkah region.