I had the same problem suddenly yesterday. Gmail would work OK in a browser, or on my iPhone, but on my iMac running Mountain Lion it wouldn't let me log in. And this was for only ONE of my gmail accounts -- the other one worked fine.
I tried the process Cleater suggested and it didn't work for me, as I already had those settings.
Then I went to support.google.com > Gmail > Troubleshoot issues > Email clients, offline & accessibility > My client isn't accepting my username and password, and chose this option:
If you're still having problems, visit http://www.google.com/accounts/DisplayUnlockCaptcha and sign in with your Gmail username and password. If necessary, enter the letters in the distorted picture.
After I'd clicked on that link, I received this message:
"Account access enabled
Please try signing in to your Google account again from your new device or application."
It never actually showed me a captcha, maybe because I was logged in to google in the browser at the time??? (not sure)
Went back to Mail on my iMac, and voila! all those stockpiled emails began coming in.
So I don't really entirely know what I did. But it worked. We await with interest to see if it's still working tomorrow!! :-)