After a six-year investigation, High Court judge Pablo Ruz said there was sufficient evidence to try the suspects over their role in the so-called "Gurtel" case, one of Spain's biggest ever graft scandals.
No date for the trial has been set.
The massive bribes-for-contracts scheme allegedly extended to six regional Popular Party governments and operated from 1999 to 2009, when investigations into the case began.
The case has been a source of deep embarrassment to Prime Minister Mariano Rajoy, who faces a general election at the end of the year in which new anti-establishment party Podemos which has rallied against corruption is poised to make huge gains.
It is one of a series of high-profile corruption scandals involving politicians of all political stripes, businesses, football clubs and even the king's sister. Hundreds of people have been charged in corruption cases and are awaiting trial.
Health Minister Ana Mato resigned in November 2014 after the judge accused her of benefiting from the kickback scheme, becoming the first government casualty in a series of cases of alleged graft.
She faces questions from the judge on whether she knew of the provenance of gifts to her family such as hotel stays, flights and luxury goods.
Her ex-husband, a former Popular Party mayor in Pozuelo de Alarcon, an upscale Madrid suburb, has been charged with receiving money and gifts in return for public works contracts.
The day after she resigned Rajoy presented two anti-corruption laws in parliament.
The judge ordered 36 of the 40 suspects, including three former Popular Party treasurers, businessmen and local officials, to pay a combined court bond of €449 million ($500 million).
The highest court bond was set for former treasurer Luis Barcenas, who was ordered to pay €88 million.
Barcenas has admitted to chaneling millions of euros in donations from builders and other business leaders into the pockets of Popular Party leaders.
But he has denied that a personal fortune which he was found to have in a Swiss bank came from the fund he oversaw. He claims he earned it from art dealing and other investments.
Spanish anti-corruption prosecutors have called for Barcenas to be jailed for 42 years for his alleged role in the kickback scheme.
The judge ordered the alleged mastermind of the scheme, businessman Francisco Correa, to pay a bond of €60 million.
The 40 were ordered to stand trial for crimes allegedly carried out between 1999 and 2005. Investigators are still looking into other crimes that allegedly took place between 2006 and 2009 as part of the case.