These lecture notes and example problems are based on a course given at the University of Cambridge in Part III of the Mathematical Tripos. Fluid dynamics is involved in a very wide range of astrophysical phenomena, such as the formation and internal dynamics of stars and giant planets, the workings of jets and accretion discs around stars and black holes, and the dynamics of the expanding Universe. Effects that can be important in astrophysical fluids include compressibility, self-gravitation and the dynamical influence of the magnetic field that is 'frozen in' to a highly conducting plasma. The basic models introduced and applied in this course are Newtonian gas dynamics and magnetohydrodynamics (MHD) for an ideal compressible fluid. The mathematical structure of the governing equations and the associated conservation laws are explored in some detail because of their importance for both analytical and numerical methods of solution, as well as for physical interpretation. Linear and nonlinear waves, including shocks and other discontinuities, are discussed. The spherical blast wave resulting from a supernova, and involving a strong shock, is a classic problem that can be solved analytically. Steady solutions with spherical or axial symmetry reveal the physics of winds and jets from stars and discs. The linearized equations determine the oscillation modes of astrophysical bodies, as well as determining their stability and their response to tidal forcing.