India's highest court has said that politicians with a "criminal background" should not serve in government – but stopped short of forcing Narendra Modi to fire the 13 cabinet members facing charges including rape, attempted murder and criminal intimidation.

Modi won a landslide victory in May partly because of his promise of clean governance, after the previous Congress-led government was mired in a string of corruption scandals. But 13 of his 45 ministers have been charged with criminal offences, with eight facing serious charges according to an analysis of their own election affidavits by the Association of Democratic Reforms, a New Delhi-based advocacy group.

In its ruling on Wednesday, the supreme court said it could not disqualify the ministers, as the constitution allows prime ministers to appoint their own cabinets, but said it hoped the premier would.

"Will any reasonably prudent master leave the keys of his chest with a servant whose integrity is doubted?" the panel of five judges asked, adding, "corruption is an enemy of the nation. As a trustee of the constitution, the PM is expected not to appoint unwarranted persons as ministers."

The court made its ruling in response to a petition seeking to stop MPs charged but not yet convicted of crimes from being appointed ministers in state and federal governments. India bans people convicted of serious crimes from holding office, but not those facing charges.

One minister, Uma Bharti, has 13 criminal cases pending against her, some related to the controversial tearing down of a mosque in Ayodhya by Hindu nationalists in 1992. The transport minister, Nitin Gadkari, faces four cases, including one alleging criminal intimidation.

Rakesh Dwivedi said the court made a landmark decision that went beyond advising the PM. Photograph: Sajjad Hussain/AFP/Getty Images

Modi's aide and the president of the ruling Bharatiya Janata party, Amit Shah, faces charges of ordering extrajudicial killings and of extortion.

Shaina Nana Chudasama, the spokeswoman for Modi's Hindu nationalist party, said that some charges against politicians were filed due to political vendettas.

But Rakesh Dwivedi, a senior advocate who was appointed to help the court in this case, called the verdict a landmark decision that went beyond simply advising the prime minister.

"It should clinch the matter and now it is largely up to the prime minister and chief ministers of the country to make sure that the letter and spirit of the verdict are honoured," he told India's NDTV.

During the election campaign, Modi promised to fast-track cases against elected political leaders.

"Just give me one chance to clean the system," he told a rally in his home state of Gujarat in April. "I will set up special courts under the supervision of the supreme court to try all the tainted MPs and MLAs, that too within [a] one-year time limit. After one year, those who are guilty will go to jail."

But since taking office in May, Modi has not addressed the issue further. Until last July, convicted Indian MPs could continue in office simply by filing endless appeals in the country's slow, inefficient court system.

However, the Indian supreme court ruled then that any MP sentenced to more than three years in prison should be disqualified from office regardless of appeals.