The answer varies depending on your situation. Here is a description of the current guidelines which have recently changed. If you had extenuating circumstances, the time periods could be shorter. Extenuating circumstances are events such as:
Death (not yours, of course)
Accident Resulting in Severe Injury
Generally, extenuating circumstances are things that happen beyond your control, which dramatically affect your ability to continue making payments on your mortgage. With documented extenuating circumstances, the waiting period is less than without.
Waiting Period to Buy After Foreclosure
Buying After a Foreclosure
The waiting period is 5 years up to 7 years.
Buying After a Foreclosure With Extenuating Circumstances
The waiting period is 3 years up to 7 years.
Buying After After a Deed-in-Lieu of Foreclosure
The waiting period is 4 years up to 7 years.
Buying After a Deed-in-Lieu of Foreclosure With Extenuating Circumstances
The waiting period is 2 years up to 7 years.
Buying After a Short Sale
The waiting period is 2 years.
Therefore, if you have no extenuating circumstances, you will need to wait four years from the date of completion, meaning the date your deed-in-lieu of foreclosure was recorded.
In addition to the waiting period, some loans require 10% down and a minimum FICO score. The home you purchase must be your principal place of residence, not a rental nor a vacation home.
Fannie Mae constantly issues new guidelines. The above policies are in effect for loan applications submitted after August 1, 2008.