From:
http://mypercept.co.uk/articles/meaning-masjid-quran.html2:187 Lawful for you nights (of) the abstinence is sexual approach* to your women, they are a garment for you and you are a garment for them. God knows that you used to betray/deceive yourselves so He turned towards you and He forgave you; so now approach** them and seek what God has decreed/written for you. And eat and drink until becomes distinct the white thread from the black thread, of dawn. Then you shall complete the abstinence until the night, and do not approach** them while you are devoting/cleaving in the maSaJiD. These are God's boundaries, so do not transgress them. It is thus that God makes His revelations clear to the people that they may be righteous/God-concious.
*Arabic: RaFaTh (root: Ra-Fa-Tha)
**Arabic: BaShiR (root: Ba-Shin-Ra)
IF one takes masajid=mosques then if women were not allowed in them, it would make this statement illogical, thus clearly implying women could be present in the mosques. It also implies men and women are unlikely to be segregated, as they could approach one another, i.e. interact.
Who in their right mind would approach their wife in a sexual manner in a public Mosque? Was this such a temptation or common practice that AQ had to tell them not to do it? According to history/tradition mosques in those early days were very basic or simply courtyards thus unlikely to have multiple rooms so it seems even more odd to suggest such a thing taking place in a Mosque. This traditional understanding verges on the nonsensical.
IF masajids=mosques, why even mention mosques, when there is much greater chance of sexual temptation in the homes during abstinence? The traditional commentators attempt an explanation for this, e.g Jalalayn/Ibn Kathir say this is referring to 'itikaf' (spiritual retreat in the mosque) when believers would leave the mosque for sex then return, when they are meant to reside at the mosque for a certain number of days. This is a complete insertion of course, and hardly "clear" as it implies at the end of the verse, and the obvious error as it says "...WHILE YOU are devoting/cleaving IN the masajid" not when one leaves them. So, it would seem they interpret it as "...while you are staying in the masajid (for itikaf)...".
If it did mean 'itikaf' then this is not explained elsewhere in AQ, e.g. how many days, what does it involve, why, is it obligatory, examples of anyone actually doing it etc. If we are relying upon AQ only for our understanding of this verse, then 'itikaf' must be rejected outright. The consequence of this however, is that it renders the understanding of masajid=mosques illogical, or at least very unusual.
Another explanation put forth for this verse is that sexual approach to your women is permitted in the nights of the abstinence but not when one is staying in the mosques, e.g. The Sacred Mosque (in Mecca). Not for "itikaf" per se but simply a spiritual/devotional retreat there, e.g. travellers to The Sacred Mosque (in Mecca) may have come from afar and thus set up tents there, and this verse is referring to them (a verse cited to support this notion of "residency/staying" is 22:25). Not that I necessarily agree with this explanation, but it is at least more plausible than the Traditional explanation, which advocates a specific practice of "itikaf" rather than an undefined one. It is debatable whether the word "akif" means "reside/stay" according to Quran usage, but in any case people staying-over in the mosque seems odd/impractical if one takes "tawaf" as "circumambulation" for example, and the "hadiy" (gifts/offerings) are also to be taken to such a venue. It could make "circumambulation" rather awkward, and if many residents/gifts/animals, perhaps impossible.