Dear Shiva,
In this case, as the employee is of the Service Provider (Contractor), he is liable to pay the Gratuity to his employee. The Service Provider (Contractor) will then claim that gratuity amount from the Principal Employer, if not already paid, through valid Invoice. After this, the PE should pay the Invoice to the Service Provider.
It is recommended that, as you are the PE, you should force the Service Provider to settle the a/c of such employee and ask him to pay all the legal dues due to such employee. Assure them that as the PE, your organization will pay-back them that amount against invoice of Full & Final Settlement along with all supporting papers, if not already paid. Otherwise, it could create more problem for your organization, as you are the PE.
Hope this will help you.