Although measuring the gas metallicity in galaxies at various redshifts is crucial to constrain galaxy evolutionary scenarios, only rest-frame optical emission lines have been generally used to measure the metallicity. This has prevented us to accurately measure the metallicity of dust-obscured galaxies, and accordingly to understand the chemical evolution of dusty populations, such as ultraluminous infrared galaxies. Here we propose diagnostics of the gas metallicity based on infrared fine structure emission lines, which are nearly unaffected by dust extinction even the most obscured systems. Specifically, we focus on fine-structure lines arising mostly from HII regions, not in photo-dissociation regions, to minimize the dependence and uncertainties of the metallicity diagnostics from various physical parameters. Based on photoionization models, we show that the emission-line flux ratio of ([OIII]51.80+[OIII]88.33)/[NIII]57.21 is an excellent tracer of the gas metallicity. The individual line ratios [OIII]51.80/[NIII]57.21 or [OIII]88.33/[NIII]57.21 can also be used as diagnostics of the metallicity, but they suffer a stronger dependence on the gas density. The line ratios [OIII]88.33/[OIII]51.80 and [NII]121.7/[NIII]57.21 can be used to measure and, therefore, account for the dependences on the of the gas density and ionization parameter, respectively. We show that these diagnostic fine-structure lines are detectable with Herschel in luminous infrared galaxies out z=0.4. Metallicity measurements with these fine-structure lines will be feasible at relatively high redshift (z=1 or more) with SPICA, the future infrared space observatory.