The German voter casts two votes:
a) The first vote is to select local representatives in 299 constituencies through a first-past-the-post system, meaning that the local candidate with most votes is directly elected.
b) The second vote is to choose a party list at a state level.
This means that voters can select their local candidate from one party and the state list from another party.

-Ballot from the 2005 German Federal Elections-
It is the results on the party list vote that determine how many out of the total of 598 seats of the Bundestag (the German federal parliament) will be proportionally allocated to every party which has reached the 5% threshold.
Finally, each party’s total seats are comprised a) by the number of representatives it elected through the first vote plus b) the required number from the party list vote in order to reach the number of seats it is entitled to, according to the second vote.
If through this process absolute proportionality for every party is not achieved, then additional seats are added to the total number of seats until proportional representation is reached for every party (the so-called overhang seats).
For example, if a party gets 30% of the party list vote, it will be entitled to 180 seats. If it has directly elected 100 local candidates, the remaining 80 will come from the party list vote. In the extremely unlikely case that it has elected all its 180 representatives through the first vote, then it will not get any seat from the second.
Candidates elected through the first vote do not lose their seat even if their party does not reach the 5% threshold, however this has rarely happened.
The electoral system is the main reason that Germany is governed by coalition governments since 1949.
Metapolls.net