The interest in installing photovoltaic (PV)-based microgrids has increased significantly in the last few years due to the urgent need for reducing greenhouse gas emissions and improving the reliability as well as the quality of power supply, particularly in developing countries. The design of a microgrid is challenging since multiple components and complicated operating conditions have to be taken into account. In this article, a comprehensive method for optimal design of a class of residential PV-battery microgrids is proposed to determine the optimal number of lead-acid batteries and PV panels, the optimal battery bank depth of discharge (DOD) value, and the optimal tilt angle of the PV panels. The aim of the optimization is to minimize the levelized cost of energy (LCOE) where the limitation of the annual total loss of the power supply and the operational constraints are considered. In addition, a detailed model for battery lifetime estimation is introduced based on the physico-chemical mechanism of the lead-acid battery. Moreover, the effect of design parameters, e.g., the size and DOD of the battery bank on the battery capacity degradation, the PV-panel number and battery lifetime on LCOE, is investigated. Computation results demonstrate that the proposed method is capable of optimizing the size of the microgrid components and the other design parameters while satisfying all technical and operational constraints.