Good afternoon.. Welcome to the forum.
Sorry to hear about your problem.
On a fuel injected vehicle it is usually very bad to run completly out of gas. When this happens your injectors usually need to be primed. Your vehicle is not getting the proper fuel/air mixture causing your system to fault (Service engine / run rough) What year is your 525?
I don't know how to fix this yourself. The last time this happened to me I had to take it to the dealership for repairs.
2004 325ci (SOLD)
1995 540i (FOR SALE)
1989 325 Convertible (Track Car)