Pipelines are one of the most efficient methods to transport large quantities of natural gas from gas reserves to main markets. However, because of the unsteady nature of gas flow, the operation of pipelines is always dynamic. Furthermore, the uncertainties in demand and the fluctuation of gas composition also make the efficient operation of these dynamic processes challenging. This study addresses the problem of determining the optimal operation to minimize compression costs, while considering demand and gas composition uncertainties. A dynamic pipeline network model is developed with rigorous thermodynamic equations, allowing accurate calculation of gas compressibility factor at any temporal and spatial point. The supply gas composition and demand nodes flow rates are assumed to be uncertain. To deal with these uncertainties, a robust optimization algorithm is applied using back-off constraints calculated from Monte Carlo simulation. Through successive iterations, the algorithm terminates at a solution that is robust to a specified level of process variability with minimal cost. We show from the case studies that the formulated model and the algorithm can successfully address the problem with acceptable computational cost.