You will need to test to determine if the gauge or the sending unit is truly at fault. I sounds like an electrical connection problem somewhere, maybe in the sending unit itself, maybe not.

Even with the light off, if the check engine light came on it should have stored a code. Have you checked for stored codes?