مَرَرْتُ بِمَسَاجِدِ الْمَدِينَةِ — I passed by the city's mosques.
بِـ: preposition.
مَسَاجِدِ: genitive with kasra and the muḍāf.
الْمَدِينَةِ: muḍāf ilayh, genitive with kasra.
The first noun takes genitive kasra here because it enters iḍāfa, unlike bare بِمَسَاجِدَ.