The petrophysical inversion of seismic data is one of the key components of seismic reservoir characterization. The goal of petrophysical inversion is to estimate the petrophysical properties of reservoir rocks, such as porosity, volumes of minerals or lithologies, and water and hydrocarbon saturations, from seismic data. This process can be performed by combining seismic amplitude-variation-with-offset (AVO) modeling and rock-physics relations with deterministic or probabilistic inverse theory methods, either in a two-step approach based on seismic AVO inversion and rock-physics inverse mapping or in a single-loop step that includes both. We present a comprehensive MATLAB library named Geostatistical Petrophysical Inversion. The novelty of the library lies in a single-loop geostatistical inversion method based on probability field simulation and ensemble smoother multiple data assimilation, as well as its implementation for applications to 3D data sets. The library also includes a Bayesian petrophysical inversion based on the two-step approach for comparison. We illustrate the main algorithms, explain the structure of the source codes, and demonstrate the library applications through 1D and 3D examples.