Mercedes Benzes from the early 1980's thru about 1995 are the true definition of reliable and long lasting. Mercedes had a very, very dark period from the late 1990's thru about 2006. BMW, IMO, was very behind Mercedes in regards to reliability until the mid 1990's, and then I think BMW became very reliable.
My last 3 new BMWs (2006-2008) have pretty much sucked. Out of the 32 brands sold in the USA, JD Powers ranked BMW #21 and Mercedes #4. A few years ago though, Mercedes was #32. Ouch. BMW always makes somewhat better handling cars, and their inline 6 cylinder engines are awesome, but in my experience, Mercedes nowadays is more reliable than BMW.