Rajoy had asked to testify by videoconference but the court ruled he must appear in person to answer questions.
He will testify at a court in San Fernando de Henares near Madrid on July 26.
The so-called Gurtel trial centres on a vast kickbacks scheme that allegedly helped finance his Popular Party (PP), which today has been weakened by repeated accusations of graft.
While Spain's 62-year-old leader is not accused of anything, his post as party chief since 2004 means he could provide valuable testimony.
Two former prime ministers -- Felipe Gonzalez, an ex- Socialist leader, and Adolfo Suarez, prime minister during the transition -- appeared on court in separate trials in 1998 after they were no longer in office.
The Gurtel case allegedly saw companies shower former PP lawmakers and civil servants with bribes in exchange for contracts.
Altogether, 37 defendants face justice including two former party treasurers and businessman Francisco Correa, the alleged head of the network.
According to a confession published by Correa in online daily eldiario.Es, companies would give him a commission of two to three percent on the value of public contracts.
After taking his share, he would allegedly give politicians involved in awarding contracts some of the money too.
He also claimed he gave money to Luis Barcenas, the PP's manager and treasurer from the 1980s until 2009.
Disclaimer: No Business Standard Journalist was involved in creation of this content
