"There were two groups inside the mosque."
Translation:In der Moschee waren zwei Gruppen.
Using es gibt (past: es gab) is more for abstract expressions of "there is/are" (past: "there was/were"). For describing locations, use (da/dort) ist/sind (past: (da/dort) war/waren).
Im Frühling gibt es viele Blumen = "In spring there are a lot of flowers"
Es gibt verschiedene Möglichkeiten = "There are several possibilities"
Dort ist ein Eichhörnchen = "There's a squirrel"
Da sind zehn Äpfel im Korb = "There are ten apples in the basket"
If I instead swapped these phrasings around it would sound different. Im Frühling sind viele Blumen da sounds like I'm referring to a specific place where many flowers grow in spring, rather than to the general prevalence of flowers everywhere at springtime. Es gibt zehn Äpfel im Korb likewise feels like it refers to some fixed combination of apples in baskets - like I'm a fruit seller who sells baskets of various fruit and someone wants to know how many apples are in my apple basket product.
So with reference to this specific sentence, using es gab would just make it sound like the mosque somewhat permanently had these two groups in it.
That is how I was thinking of it. There were two groups, ie. Sunni & Shia, traditionalist and modernist or men's group and women's group and they both shared this Mosque at the same time. .... say, before the war or until they could build separate mosques in their new homeland.
So, based on your last paragraph, es gibt is not just for abstract expression but can be used for describing locations when there's a sense of permanence? For instance, in this lesson I also received the sentence Es gibt drei Tempel in dieser Stadt. Was it OK to use es gibt in that case because those temples are presumably not going anywhere any time soon, whereas the groups in the mosque were there at a certain time?
I'm just practicing for the entire course and I don't know which lesson introduces this (new?) sentence. So I think “es gab” shouldn't be omitted or rejected.
I also wrote "es gab", while I get that maybe there are translation nuances, they shouldn't mark it as completely incorrect. As my teacher would put it, it's unusual, but still correct. Besides, "there is" translates to "es gibt" in German like "il y a" in French, it's an equivalent construction.