جَلَسْتُ فِي الْمَسْجِدِ
Translation: I sat in the mosque.
جَلَسْتُ: past verb with subject.
فِي: preposition.
الْمَسْجِدِ: genitive after fī.
فِي الْمَسْجِدِ: phrase describing the place of sitting.
Because fī is explicitly present, the noun is genitive, not an accusative adverbial.