Yes, a foreigner can buy a villa in the freehold zone of Dubai and obtain a residence permit. The minimum amount of investment in real estate is AED750,000 (~$204,000) for obtaining a 2-year residence permit, and AED 2,000,000 (~$545,000) for obtaining a 10-year residence permit.