The random design nonparametric regression model with short-range dependent and long-range dependent errors is investigated. The asymptotic behaviour of the robust local polynomial M-estimator is investigated under two conditions. Asymptotic results are established by decomposing the local polynomial estimator into two terms: a martingale term and a conditional expectation term. It is found that the local polynomial M-estimator is asymptotically normal when errors are short-range dependent. When the errors are long-range dependent, a more complex behaviour is observed that depends on the size of the bandwidth. If the bandwidth is small enough, the long-range dependent scenario is similar to the the short-range dependent case. If the bandwidth is relatively large the asymptotic result is more intricate and the long-range dependent variables dominate. Moreover, the optimal bandwidth in the case of short-range dependence is determined.