Tower repairs and maintenance costs decreased by $20.6 million in the three month period ended June 30, 2024, compared to the three month period ended June 30, 2023, primarily driven by lower costs in our SSA segment due to unwinding of the power managed service agreement and local currency devaluation in our Nigeria segment.
Costs for security services decreased by $11.2 million in the three month period ended June 30, 2024, compared to the three month period ended June 30, 2023, primarily driven by lower costs in our SSA segment due to unwinding of the power managed service agreement. The decrease was also driven by lower costs in our Nigeria segment, solely due to the Naira devaluation discussed above, even though the underlying local costs increased.
Power generation costs decreased by $8.0 million in the three month period ended June 30, 2024, compared to the three month period ended June 30, 2023, of which $5.8 million of the decrease related to diesel costs and $2.2 million of the decrease related to electricity costs. The decrease in diesel costs was primarily driven by our SSA segment where there was a year-on-year decrease in the diesel price per liter in U.S. Dollars of 0.5% and an overall consumption decrease of 12.4%.
Costs for site regulatory permits decreased by $3.2 million in the three month period ended June 30, 2024, compared to the three month period ended June 30, 2023, primarily driven by lower costs in our Nigeria segment, solely due to the Naira devaluation discussed above, even though the underlying local costs increased.
Remaining cost of sales line items decreased by $18.8 million in the three month period ended June 30, 2024, compared to the three month period ended June 30, 2023. This was driven by a decrease in net foreign exchange losses on cost of sales, from net foreign exchange gains of $1.9 million in the three month period ended June 30, 2024, compared to $16.9 million in net foreign exchange losses on cost of sales in the three month period ended June 30, 2023, primarily driven by our Nigeria segment.
The decrease in cost of sales of $142.8 million, or 23.6%, in the six month period ended June 30, 2024, compared to the six month period ended June 30, 2023, is primarily due to decreases in depreciation and amortization costs, power generation costs, tower repairs and maintenance costs and security services costs.
Aggregate depreciation and amortization decreased by $59.7 million in the six month period ended June 30, 2024, compared to the six month period ended June 30, 2023, primarily driven from a decrease in Nigeria’s segment asset base.
Power generation costs decreased by $34.5 million in the six month period ended June 30, 2024, compared to the six month period ended June 30, 2023, of which $37.2 million of the decrease related to diesel costs partially offset by $2.7 million related to electricity costs. The year-on-year decrease in diesel costs was primarily driven by our Nigeria segment where there was a decrease in the diesel price per liter in U.S. Dollars of 21.4% and a decrease in our SSA segment where there is an overall consumption decrease of 19.2%.
Tower repairs and maintenance costs decreased by $32.9 million in the six month period ended June 30, 2024, compared to the six month period ended June 30, 2023, primarily driven by lower costs in our Nigeria segment, solely due to the Naira devaluation discussed above, even though the underlying local costs increased.
Costs for security services decreased by $16.2 million in the six month period ended June 30, 2024, compared to the six month period ended June 30, 2023, primarily driven by lower costs in our SSA segment due to unwinding of the power management service agreement. The decrease was also driven by lower costs in our Nigeria segment, solely due to the Naira devaluation discussed above, even though the underlying local costs increased.
Remaining cost of sales line items increased by $0.5 million in the six month period ended June 30, 2024, compared to the six month period ended June 30, 2023.
Gross margins
The gross margin improved by 6.9 percentage points, to 52.5% for the three month period ended June 30, 2024, compared to 45.6% for the three month period ended June 30, 2023, resulting from a decrease in revenue of 20.3% discussed above, alongside a decrease in cost of sales of 30.4%.