A stable dye-sensitized solar cell (DSSC) was fabricated by a novel in situ gelation of the electrolyte. A highly condensed oligosiloxane gel was formed by sol-gel reaction of silane monomers. The oligosiloxane gel DSSC showed reduced charge recombination, and an efficiency of 5.8% with long-term stability.