When electrical charges "stand still", as opposed to "move around" (which is called an electric current)
Static electricity is usually generated by friction. For example, rubbing a polythene rod with a cloth will cause electrons to move from one object to the other. The object the electrons move to will gain a negative charge and the object the electrons move away from will gain a positive charge.