We propose a cointegration-based Permanent-Transitory decomposition for nonstationary dynamic factor models (DFMs). Our methodology exploits the cointegration relations among the observable variables and assumes they are driven by a common and an idiosyncratic component. The common component is further split into a long-term nonstationary and a short-term stationary part. A Monte Carlo experiment shows that incorporating the cointegration structure into the DFM leads to a better reconstruction of the space spanned by the factors, compared to the most standard technique of applying a factor model in differenced systems. We apply our procedure to a set of commodity prices to analyse the co-movement among different markets and find that commodity prices move together mostly due to long-term common forces; while the trend for the prices of most primary goods is declining, metals and energy exhibit an upward or at least stable pattern since the 2000s.