Gas injection can increase oil recovery because the gas–oil interfacial tension is less than the water–oil interfacial tension (IFT) and tends to zero in the miscibility state. However, little information has been provided on the gas–oil movement and penetration mechanisms in the fracture system at the porosity scale. The IFT of oil and gas in the porous medium changes and can control oil recovery. In this study, the IFT and the minimum miscibility pressure (MMP) are calculated using the cubic Peng-Robinson equation of state that has been modified using the mean pore radius and capillary pressure. The calculated IFT and MMP change with the pore radius and capillary pressure. To investigate the effect of a porous medium on the IFT during the injection of CH4, CO2, and N2 in the presence of n-alkanes and for validation, measured experimental values in references have been used. According to the results of this paper, changes in IFT vary in terms of pressure in the presence of different gases and, the proposed model has good accuracy for measuring the IFT and the MMP during the injection of hydrocarbon gases and CO2. In addition, as the average radius of the pores gets smaller, the interfacial tension tends to lower values. This effect is different with increasing the mean size of interstice in two different intervals. In the first interval, i.e. the Rp from 10 to 5000 nm, the IFT changes from 3 to 10.78 mN/m and in the second interval, i.e. the Rp from 5000 nm to infinity, the IFT changes from 10.78 to 10.85 mN/m. In other words, increasing the diameter of the porous medium to a certain threshold (i.e. 5000 nm) increases the IFT. As a rule, changes in IFT affected by exposure to a porous medium affect the values of the MMP. In general, IFT decreases in very fine porous media, causing miscibility at lower pressures.