If you are looking for an exception to the 10% "penalty" on early withdrawals - you can avoid the 10% early withdrawal penalty if the funds come from an IRA, but not from a 401K.
See this IRS link: Exception to 10% Additional Tax
You will see a YES in the IRA column for ''qualified first-time homebuyers, up to $10,000''
See this TurboTax tips article for more information on this topic.