The aim of this research is to perform an in-depth performance comparison of ground-mounted and rooftop photovoltaic (PV) systems. The PV modules are tilted to receive maximum solar irradiance. The efficiency of the PV system decreases due to the mutual shading impact of parallel tilted PV modules. The mutual shading decreases with the increasing interrow distance of parallel PV modules, but a distance that is too large causes an increase in land cost in the case of ground-mounted configuration and a decrease in roof surface shading in the case of rooftop configuration, because larger sections of roof are exposed to sun radiation. Therefore, an optimized interrow distance for the two PV configurations is determined with the aim being to minimize the levelized cost of energy (LCoE) and maximize the energy yield. The model of the building is simulated in EnergyPlus software to determine the cooling load requirement and roof surface temperatures under different shading scenarios. The layout of the rooftop PV system is designed in Helioscope software. A detailed comparison of the two systems is carried out based on energy output, performance ratio, capacity utilization factor (CUF), energy yield, and LCoE. Compared to ground-mounted configuration, the rooftop PV configuration results in a 2.9% increase in CUF, and up to a 23.7% decrease in LCoE. The results of this research show that installing a PV system on a roof has many distinct advantages over ground-mounted PV systems such as the shading of the roof, which leads to the curtailment of the cooling energy requirements of the buildings in hot regions and land cost savings, especially for urban environments.