It’s a common question: Should I borrow from my 401(k) to buy a house? With all that money sitting untouched in an account, it can be tempting to loan yourself some cash for a down payment on the home of your dreams—but is it a good idea?

The answer depends on your circumstances, but there are important factors to consider before you make a withdrawal.

One feature of 401(k) loans is that you are paying yourself back to your 401(k) balance instead of that money going to a bank, says Bob Gavlak, a Certified Financial Planner and wealth advisor with Strategic Wealth Partners in Columbus, Ohio. This type of loan typically carries an interest rate that is lower than a bank loan, based on the prime lending rate, and it requires less paperwork than other types of loans. Fees are minimal depending on your provider, and they may be lower than the fees associated with a bank loan.

Some 401(k) plans allow employees to borrow up to 50 percent of their balance (up to a maximum of $50,000).

However, a loan from your 401(k) would come with a few important caveats. First, the maximum repayment period is typically five years, according to Gavlak. Plus, when you borrow from your retirement savings, you miss out on potential growth.

“Instead of your 401(k) deferrals going into something that might earn money, you’re paying back this loan and then only getting a little bit of interest,” Gavlak says.

But perhaps the biggest risk with 401(k) loans is that if you leave your job or get laid off before the loan is repaid, the remaining balance becomes payable within 60 days.

“If there’s any chance or thought that you could be leaving your job, a 401(k) loan is really not a good idea,” Gavlak says. “A lot of times people end up having to take a distribution [from the 401(k)] and pay not only income tax but a 10 percent early withdrawal penalty as well.” If this is a possibility, then a bank loan (even with a higher interest rate) may offer more favorable terms because it’s not contingent on staying with an employer for the duration of the loan.

To answer your question, if you pursue this strategy, you would be borrowing around 15 percent of your 401(k) balance for your investment property purchase. You indicate that you have enough in liquid savings to cover the down payment but prefer not to use it. If you move forward with the 401(k) loan and you or your spouse later gets laid off or decides to switch jobs, perhaps you could use your liquid savings to pay off the loan and avoid early withdrawal penalties and taxes. Then, instead of making payments toward your 401(k) loan, you could reallocate that money to build up your liquid savings again.

Gavlak says this could be a reasonable plan, but he urges you to consider other options as well. For example, if the mortgage on your primary residence is already paid off, Gavlak suggests that it might make sense “to take out a mortgage on [your] house, get the tax deductibility of that, and use the money for the investment property.”

You should also consider any outstanding debts (such as a car payment, an existing mortgage, or credit card balances) before taking on any type of loan.

Given the risks involved with 401(k) loans, Gavlak advises against treating your 401(k) like an ATM. “If it’s being utilized to pay living expenses or go on a vacation, that’s not a good idea,” he says. However, he has seen people successfully use a 401(k) loan to purchase an investment property “as long as they understand the risks and the operational side of how [it works].”

Susan Johnston is a Boston-based freelancer who has covered personal finance for numerous publications including Bankrate.com, the Boston Globe, Learnvest.com, Mint.com, and USNews.com. Find out more at www.susan-johnston.com.