Static electricity is an imbalance of electrical charge on an object. The charge on the object remains until it is 'discharged'. A static charge is built up when two surfaces contact each other. Rubbing two materials together can cause a transfer of negative electrons. Remembering that atoms are made of protons, neutrons, and electrons and have a neutral charge. When the electrons are transferred it causes an imbalance of electrons on the atoms. These charges will continue to build up until they are discharged or released.
For example, rubbing your foot on a carpet results in your body rubbing electrons off of the carpet which builds up a charge on your body. This charge will remain built up on your body until you touch something like a metal doorknob where the electrons are discharged resulting in an electric shock.
"The static electricity phenomenon requires a separation of positive and negative charges. When two materials are in contact, electrons may move from one material to the other, which leaves an excess of positive charge on one material, and an equal negative charge on the other. When the materials are separated they retain this charge imbalance..."
When two like charges (positive and a positive) come near/contact each-other they will repel each other.
When two opposite charges (negative and a positive) come near/contact with each other, they will be attracted to each other.