The 450km (280-mile) Haramain Express line linking Mecca and Medina via the Red Sea city of Jeddah has 35 trains that can travel up to 300km/h (186mph).
Officials hope it will transport 60 million passengers annually and ease traffic congestion for Muslim pilgrims.
The railway is due to begin operating commercially next Monday.
There will be eight services a day in both directions until the end of this year, when the frequency will be increased to 12.
“The journey between the Haramain [two holy mosques] is now shorter and easier than at any time before,” Transport Minister Nabil al-Amoudi told dignitaries at a ceremony in Jeddah on Tuesday.
“The project highlights the kingdom’s commitment to serving Islam and Muslims.”
Muslims travelling between Mecca and Medina for the Hajj or Umra pilgrimages have faced a bus journey of up to six hours. They could now do the journey by train in just over two hours.
Mecca’s station, about 4km (2.5 miles) from the Grand Mosque, will be able to handle as many as 20,000 passengers per hour.
The railway was built in two phases by two consortiums involving Saudi, French, Chinese and Spanish companies. It has taken six years more to complete than was originally planned.