I recently submitted a paper in a decent journal (published by Elsevier) and it got accepted after 6 months. The referee asked for minor modifications which I did. The final version was accepted for publication and is now in press. However when I received the final version of the paper to check before it is published I discovered a small loophole in one of the proofs. Upon working on it for many days it seems to be un-fixable. The only way out was to add an extra regularity condition to the theorem which "waters down" the result. My question is what procedure will be adopted by the journal to resolve this? And can my paper be rejected at this stage?
Well, you have to fix it, don't you? Talk to the editor.
Yes, the paper may indeed be rejected, but we cannot know this.
As a reviewer, I have found subtle holes in papers, and really it would have been unwise for the authors to submit without taking care of filling the holes (which they thought they could do, but turned out was impossible, as counterexamples were published later).
TL;DR: Better a watered-down, correct result than a wrong one.