car will crank but cuts right off wont hold a crank. on 2001 BMW 325i

at night it didnt crank drove about about 2 hours to another city came out of the house and it wouldnt crank but for a little while

Asked by for the 2001 BMW 325i
need more info to help