Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
The fast is not broken by accidentally swallowing water or toothpaste. But we should exercise caution while rinsing the mouth, gargling, or brushing our teeth with toothpaste.
Responding to your question, Sheikh Ahmad Kutty, a senior lecturer and an Islamic scholar at the Islamic Institute of Toronto, Ontario, Canada, states:
The fast is not broken by accidentally swallowing water or toothpaste. Prophet Muhammad (peace be upon him) said: “Allah has excused my Ummah for their (accidental) mistakes, forgetfulness, and (idle) mental chatter over which they have no control, so long as they do not express or act upon it.”
Since it was not a deliberate act you are excused, and your fast is not broken. However, it is necessary to point out that while fasting, we should exercise caution while rinsing the mouth, gargling, or brushing our teeth with toothpaste. The Prophet said: “Exert yourself in rinsing and gargling the mouth and nostrils unless you are fasting.”
While fasting, one is supposed to do the above only sparingly, to avoid the risk of swallowing water by accident. You thus owe it to yourself to take extra care in the future so that it does not happen again.
Almighty Allah knows best.