Diamond and graphite are both naturally occurring allotropes of the element carbon.
An allotrope is a distinct structural form of the same element. Diamond and graphite contain only carbon atoms, but their atoms are bonded and arranged differently. In diamond, each carbon atom forms four strong covalent bonds in a rigid three-dimensional network, making it exceptionally hard.
Graphite has a layered structure in which each carbon atom bonds to three neighboring atoms. The layers can slide over one another, which makes graphite soft and useful in pencils and as a lubricant. Graphite also conducts electricity because some electrons are delocalized within its layers; diamond is normally an electrical insulator.
The contrast between these minerals is a classic example of how atomic structure determines physical properties. Diamond is transparent and highly resistant to scratching, while graphite is opaque and flaky. Graphite is the more thermodynamically stable form of carbon at ordinary pressure, but diamond does not quickly transform into graphite because the required structural rearrangement is extremely slow.