Maintenance and inventory control of spare parts are of great importance for efficiently managing onshore wind farms. Considering the economic and graphical dependencies among wind turbines and the stochastic degradations of the components in the turbines, this article studies the joint optimization of opportunistic condition-based maintenance and spare parts supply for onshore wind farms to minimize the operation and maintenance cost rate. For each field maintenance, the specific turbines, with failed components, are selected for replacement using a clustering method, and the shortest route for visiting the turbines with failed components is scheduled. The maintenance team departs from a maintenance center with spare parts, maintains the selected turbines with failed or degraded components, and then returns to the center. This complicated and practical problem has never been considered as a whole in the literature. An optimization model is established, and a simulation-based approach is developed to solve it. A special case, for which a solution can be obtained by directly solving a nonlinear programming model, is provided to verify the results obtained by the simulation-based approach. Examples for various scales of wind farms are provided, and an analysis is performed for determining the length of a recommended maintenance interval.