Metastability may occur if the input to a flip-flop changes just as the clock goes high. Neither logical level is read into the register; instead, the register output will be completely unpredictable, changing rapidly between 0 and 1. The output is in a metastablestate.

Modern flip-flops
In practice, metastability as described above does not occur in modern flip-flops. They are made so that the output always stays at a specific level; metastability only occurs inside the flip-flop. Unfortunately, this doesn't solve the problem completely. Metastability inside a flip-flop may cause the output to change between two clock ticks. Depending on delay to next memory elements, this can cause the signal to be read differently at two other places in the chip, leading to errors.

How to avoid metastability
Metastability is avoided by keeping to a strict, synchronous design. If all changes are caused by the clock, metastability will not take place. If you have to use an asynchronous signal, synchronise it to your clock first. Normally, two registers are used for this, placed serially (one after the other). If metastability happens in the first flip-flop, like described above, it will only spread to the next synchronising flip-flop. Chances are very slim that the metastable signal changes at the exact moment needed to make metastability in the next flip-flop as well.

In applications where stability is very important, more synchronising flip-flops may be inserted. This will increase the latency of the synchronised signal (more clock cycles are needed before a change will propagate through the synchronisation), but drastically decrease the chance of metastability.