Solar energy is harnessed from the sun's rays using photovoltaic cells in solar panels. These cells convert sunlight into direct current (DC) electricity, which is then converted into alternating current (AC) by an inverter for use in homes and businesses.