Acid gases (CO2/H2S) injected in aquifers for continuous hydrocarbon production from sour gas fields (gas reserves with acid gas contaminants) can react with the ions present in the brine. The solubility predictions are then, quite different than those without reactions. Accurate solubility estimates in the presence of such reactions are integral towards developing an effective acid gas disposal strategy for continuous production from these fields. Also, the modeling of CO2 injection in oil reservoirs entails complex interplay of flow, geochemical reactions and hydrocarbon phase behavior. The geochemical reactions affect the component mole numbers, which can change the number of hydrocarbon phases and/or affect the distribution of components in them. In this research, we propose the Gibbs free energy minimization algorithm that integrates geochemical reactions and phase behavior to find equilibrium compositions for these two applications. We use this algorithm to find equilibrium compositions for not just pure phase equilibrium (without reactions) but also phase and chemical equilibrium (with reactions). While the number and composition of the hydrocarbon phases may vary; we assume all the geochemical reactions are at equilibrium. In the first application, we use this algorithm to estimate solubility of acid gases (CO 2 and/or H2S) in pure water as well as CO2 solubility in high salinity brine. The algorithm predicts the solubility for binary systems of CO2-H2O and H2S-H 2O at high pressures and at temperatures upto 50°C. The use of Pitzer's activity coefficient model for aqueous phase components also helps predict the solubility of CO2 in high salinity brine. In the second application for hydrocarbons, we investigate the impact of geochemical reactions on the phase distribution of CH4-CO2-H2O mixture. We observe that the geochemical reactions do not change the equilibrium phase mole fractions at 50°C in the pressure range 0.1-20 MPa.