In رَأَيْتُ بَعْلَبَكَّ, the second part is accusative; its fatḥah marks the accusative.
In مَرَرْتُ بِبَعْلَبَكَّ, it is genitive; fatḥah stands in place of the expected kasrah for this diptote.
The final vowel alone does not identify the case. Identify the governing element: the verb makes an object; the preposition governs genitive.