A large-eddy simulation framework, dubbed as the Virtual Wind Simulator (VWiS), for simulating turbulent flow over wind turbines and wind farms in complex terrain is developed and validated. The wind turbines are parameterized using the actuator line model. The complex terrain is represented by the curvilinear immersed boundary method. The predictive capability of the present method is evaluated by simulating two available wind tunnel experimental cases: the flow over a stand-alone turbine and an aligned wind turbine array. Systematic grid refinement studies are carried out, for both single turbine and multi-turbine array cases, and the accuracy of the computed results is assessed through detailed comparisons with wind tunnel experiments. The model is further applied to simulate the flow over an operational utility-scale wind farm. The inflow velocities for this case are interpolated from a mesoscale simulation using a Weather Research and Forecasting (WRF) model with and without adding synthetic turbulence to the WRF-computed velocity fields. Improvements on power predictions are obtained when synthetic turbulence is added at the inlet. Finally the VWiS is applied to simulate a yet undeveloped wind farm at a complex terrain site where wind resource measurements have already been obtained. Good agreement with field measurements is obtained in terms of the time-averaged streamwise velocity profiles. To demonstrate the ability of the model to simulate the interactions of terrain-induced turbulence with wind turbines, eight hypothetical turbines are placed in this area. The computed extracted power underscores the significant effect of site-specific topography on turbine performance. Copyright © 2014 John Wiley & Sons, Ltd.