Summary Controlled laboratory experiments and some field studies have shown that the onset of sand production in gas wells differs from that in oil wells. Results from a general 3D sand-production numerical model are presented to explain the differences in the onset of sanding and sand-production volume for different fluids and under different flow and in-situ stress conditions. The sand-production model accounts for multiphase-fluid flow and is fully coupled with an elasto-plastic geomechanical model. The sanding criterion considers both mechanical failure and sand erosion by fluid flow. Non-Darcy flow is implemented to account for the high flow rates. The drag forces on the sand grains are computed on the basis of the in-situ Reynolds number. Both the intact rock strength and the residual rock strength depend on water saturation. Water evaporation (drying) resulting from gas flow is modeled using phase equilibrium calculations. The onset of sand production is compared for different fluid types (oil and gas). Model results are shown to be consistent with experimental observations reported in the literature. For example, the onset of sanding is observed at higher compressive stresses for gas wells as compared with oil wells. The primary mechanism for this is for the first time shown to be sand strengthening induced by evaporation of water. This effect is not observed in oil wells. The sand-production rate when non-Darcy effects are considered is lower than for Darcy flow. The reason for this is the lower fluid velocity (for the same drawdown) and, consequently, smaller drag forces on the failed sand grains. The effect of water breakthrough and water cut on sand production is studied from both mechanical and erosion perspectives. The model is shown to be capable of accurately predicting the onset of sanding and sand production induced by multiphase- and compressible-fluid flows, helping us to predict sanding issues in both oil and gas wells.