Shama-il Tirmidhi Chapter 25, Hadith Number 14 (156).

Abdullah bin Haarith Radiyallahu’Anhu says… “We ate roasted meat with Rasulullah Sallallahu ‘Alayhi Wasallam in the masjid”.

From this we find that it is permissible to eat and drink in the masjid, on condition that the masjid does not become untidy, otherwise it is makruh to do so. It is possible that this was at the time of i’tikaaf (in Ramadaan). It was the practice of Sayyidina Rasulullah Sallallahu ‘Alayhi Wasallam to observe i’tikaaf every year, and at that time it is obvious that one eats in the masjid.