There are two types of nonstationary time series:
1)trend-stationary process: yt=α+δt+rt, where rt is a stationary series, for example, a stationary AR(p) series;
2)unit root process: ARIMA process, a simplest example is random walk with a drift: yt= μ+yt-1+at, where at is a white noise series.
For type 1) process, we need to subtract δt (to produce a stationary process)before applying MLE to the data; for type 2) process, taking difference is indispensable (to achieve stationarity) before applying MLE.
Of course, in the first place we should test what kind of model fit the data best, and then follow the above method.