Ok, let's go back to the law on this, §23 EStG: That 10 year rule wasn't always in place, before 1999 it was just a minimum 2 year holding period, for the historical development have a look here.
So, to break this up into the above three cases cited in the law:
you sell a house/apartment in which you didn't live yourself, e.g. it stood empty all the time or was rented to somebody:
the profit (= Spekulationsgewinn) is only tax free if you sell it 10 years or more after the date you bought it
you sell a house only you lived in:
the profit is always tax free, no matter how soon you sell it (no minimum holding period).
you sell a house/apartment that was rented to someboday, but in the period before you sold it, you moved in and used it yourself:
the profit is only tax free if you had been living in it at least in the year you sold it and in the last two full calendar years. Example: you sell in 2011 a house/apartment you had previously rented out, this means that in order for the profit to be tax free, you would have had to have moved into that house/apartment on 31. December 2008 at the very latest (--> full year 2009, full year 2010, rump year 2011 until the date you sold).