Larva is the problem... the adults don't damage anything. Though some yellow sticky traps will help get rid of them and fewer means less breeding, so that's a positive. Killing from both ends of the life cycle is a good idea.
Kill the larva with Bacillus thuringiensis israelensis, or Bti. The brand name around here is Summit Mosquito Bits or Dunks. The brand name is irrelevant. The active ingredient is what matters. Dunks go in a reservoir, bits get top-dressed and watered in.
It'll probably take 3 weeks to clear up. And the damage done to the roots will take even longer to recover, i'd assume. Hopefully these are photoperiods... get'em healthy again before flowering and they'll do fine. you may see ~1 gnat at a time for a while after, but it'll mostly stamp it out on its own.
Relative to an indoor garden, gnats most often come from the store in the medium that you bought. Use BTI early on to avoid the potential problem... if you don't see any random gnat flying around after a month or so, you can cease use at that time. It's a great preventative measure that will kill off any nasty larva that come with the medium.
Hands-down the most effective thing to do.