The first rule is "Don't", or really try not to. If that doesn't work then generally (if your plan allows) you can borrow up to 50% of your vested account balance or $50k whichever is lower (min. is $1,000). Needs to be paid back over 5 years (monthly payroll deducted) and the interest rate is the "prime rate" plus one percent. The current "prime rate" can be found in the business section of your local newspaper or the Wall Street Journal. Oh, the interest is paid back you YOU.
My first suggestion would be to request a copy of your plan document and/or speak with your benefits department to retrieve details on your plan. If you haven’t done so already, you might want to verify you are able to borrow from your 401(k) for the purpose you had in mind. Some plans allow you to borrow for any reason while most have some restrictions in place. Furthermore, the interest rate is established by your employer and although it seems that most plans use prime rate plus 1-2% it wouldn’t hurt to review your plan document to confirm this. Lastly, it is possible your payback period could be extended beyond 5 years if you are borrowing funds to purchase a home. Once again, you will want to check with your plan documents or benefits department to determine your repayment period.
I think it is also important to point out that while your 401(k) contributions are made with pre-tax dollars the loan repayments will be paid with after tax dollars. This may result in you paying tax twice when you withdraw these funds in retirement. This consequence, along with others, has led many to advise against borrowing from your 401(k) if at all possible. You might consider talking with an investment professional and/or tax advisor to determine how borrowing from your 401(k) will impact you.