why does my car jerk on idle and my lights turn dim when jerking on 1999 Mazda Millenia

When I come to a complete stop my car shakes and when it shakes the lights go a little dim?

Get Your Car Fixed at a RepairPal Certified Shop.
We certify shops based on expertise, quality work, and verified customer reviews
2 answers 1 comment
i agree with #1
there are a few possibilities like low/erratic idle due to a vacuum leak will also cause lights to dim due to low charging system voltage,loose battery connections,and pretty much anything that will make the car idle low can also affect the charging system output.I would not only test the charging system,but scan for engine codes as well.
thank you!