Hydrogen production using solar energy and blending in a natural gas pipeline is a cost-effective alternative to hydrogen storage and transmission that leads to lower CO2 emissions caused by the energy infrastructure. In this paper, energy, exergy, and Exergoeconomic analyses of a solar hydrogen production system and its blending with natural gas in a city gate station of Isfahan city are performed in three days with minimum, average, and maximum solar irradiations. The system includes photovoltaic arrays, anion exchange membrane electrolyzer cells (AEMECs), a hydrogen compressor, and a system blending. The AEMEC is used due to its less expensive catalysts, non-acidic electrolyte, and high efficiency at high pressures. A three-dimensional numerical model is developed to determine the AEMEC’s polarization curve, accurately. The results show that with increasing solar irradiation and decreasing ambient temperature, the maximum power of the PV increases and the energy and exergy efficiency of the PV decreases. By increasing the injection of hydrogen into natural gas from 1% to 10% vol., the lower heating value of the fuel and the Wobbe Index decrease by 6% and 1.55%, respectively. By injection of 10% vol. hydrogen gas into natural gas compared to the case of using natural gas without hydrogen, the exergy cost of natural gas blended with hydrogen increases by 5.9%. Considering the environmental benefits of using hydrogen in combination with natural gas, including the reduction of greenhouse gases, and the fact that blending hydrogen up to 10% vol. with natural gas does not require any change in urban gas supply facilities, this process is feasible. In the case of using high-pressure AEMEC and removing the compressor to produce hydrogen at high pressure, the exergy cost of high-pressure hydrogen reduces by 29.3%.