NEW DELHI -- India's Parliament has approved a bill providing a 10 percent quota in government jobs for the poor members of upper castes who have been excluded from existing quotas for low-ranking castes.

The Congress party and other opposition parties supported the legislation, but criticized Prime Minister Narendra Modi's government for getting it approved just months before national elections, in an effort the opposition claimed was aimed at winning votes.

The Modi government surprised the opposition by unexpectedly moving the bill in the lower house of Parliament on Tuesday and getting it approved. The upper house adopted it by sitting late into night on Wednesday during the final day of the current parliamentary session. The bill now only needs the approval of India's president, a formality, to become law.

Discrimination under the caste system was outlawed soon after India's independence from Britain in 1947. But the system's influence remains strong and the government has sought to redress discrimination against those on the lower rungs by setting up quotas for government jobs and university spots.

Until now, 49.5 percent of government jobs and places in state-funded educational institutions were allocated to the lower castes.

The economically poor among higher castes have been clamoring for a similar quota to improve the quality of their lives.

Modi on Wednesday hailed the passage of the bill in Parliament in a tweet as a way for younger, economically disadvantaged Indians from higher castes "to showcase their prowess and contribute toward India's transformation."

Opposition lawmakers, including D. Raja of the Communist Party of India and Satish Mishra of the Bahujan Samaj Party, a party representing the lower castes, said the government provided the job quota to upper caste Indians to save embarrassment from its failure to create 2 millions jobs every year as promised after coming to power in 2014.

"Job quotas are being provided as a substitute for jobs," said Ashish Nandy, a well-known political commentator.

The new law will face a test in India's Supreme Court, which has put a 50 per cent cap on job quotas in the country based on social and educational backwardness.

Finance Minister Arun Jaitley said the job quota for upper castes would not be affected by any court restrictions because it was introduced because of an economic need.

Critics have said the lower castes should be strengthened through education rather than quotas because many jobs and university spots that have been reserved for them remain empty.