Sayyiduna Abdullah bin Abbas (may Allah be pleased with them both), commenting on the saying of Allah Almighty: "Nor when in a state of major impurity, except when passing through, until you have bathed" [Surah al-Nisa: 43], said: A person in a state of major impurity should also not approach the prayer until he has performed the ritual bath (ghusl), except a traveller, who may. He said: Do not enter the mosque while in a state of major impurity, unless your way passes through it; but do not sit down.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الصلاة / 4325