In this paper, an efficient closed-form expression for overvoltage of overhead lines under direct strike in the presence of lightning arresters is presented. The lightning arresters are also grounded via two grounding systems namely vertical electrode and horizontal grid. The simulation results based on the exact method show that among different parameters, the resistivity of soil and line height affect the overvoltage. To extract the closed-form expression, adaptive-network-based fuzzy inference systems (ANFIS) are used. In creating the ANFIS-based expression, it is first assumed that the electrical parameters of the soil are constant. Then a number of input-output pairs (inputs are soil resistivity and line height and the output is overvoltage) are computed from exact methods to train the algorithm. Once the algorithm is converged, the efficient expression is extracted. This simple expression can be easily used in dispersive soils (frequency-variant electrical parameters) and horizontally two-layered soils (non-homogenous electrical parameters) provided that the equivalent frequency and equivalent resistivity concepts respectively in dispersive and two-layer soils are used.