It is rigid like a solid, but its molecules are not arranged in repeating crystals. It is amorphous like a liquid. If you cool it fast enough, the molecules can't organize themselves into crystals. As the temperature drops, the liquid becomes more viscous and the molecules more sluggish. Window glass is made mostly of sand - with soda ash mixed in to lower melting temperature and limestone to decrease solubility in its final form but just about any liquid can be a glass if it is cooled quickly enough.
Some liquids are easier to turn into glass than others, however.
The more viscous a liquid is at its freezing point, the more trouble the molecules will have moving into crystalline formation, and the more likely they are to end up a glass instead. Each molecule, says chemist Mark Ediger of the University of Wisconsin, is a long, awkward chain, and so liquid polystyrene is a tangled, viscous soup. No one has ever crystallized it, says Ediger. Glass is the only solid state common polystyrene can have. Glasses are everywhere these days, from telephone cables to Life Savers and yet researchers are still arguing about their very nature.