From the way most financial experts talk, dipping into your 401(k) is somewhere in the vicinity of sticking a fork in an electrical outlet on the Don’t Do It scale.

But with stock prices plunging and unemployment rising, aren’t there some exceptions to this hard and fast rule? If you find yourself in a true financial emergency and have exhausted all other options, it might be okay to take a temporary loan from your 401(k), as long as you understand the risks.

Double Taxes and Other Risks
Borrowing from your 401(k) has such a bad reputation because it can cost you big in the long run. The money you take out of your 401(k) won’t have the opportunity to grow until you put it back. If the market goes up while you’re repaying your loan, it could mean losing a big chunk of change down the line. On top of that, you’ll have to repay your loan using after-tax dollars. When you take the money out in retirement, you’ll end up having paid taxes on it twice.

Where you really get into trouble is if you can’t pay back the loan. If your job security is somewhat questionable, dipping into your 401(k) is not a good idea. If you lose your job, the loan will come due very quickly, usually in 90 days. If you don’t repay the loan in that amount of time and you’re less than 59 and a half years old, you’ll have to pay a 10% withdrawal penalty.

So When Is It OK?
A 401(k) loan should always be considered a last resort. The only time it really makes financial sense to do it is when you know you’ll be able to pay it back quickly. If you are expecting a large settlement or a bonus that’s guaranteed, you won’t lose much by borrowing from your 401(k) for a short time. It’s better than racking up high-interest debt on a credit card to get out of a jam. Paying interest back to yourself is certainly preferable to paying it to a credit card lender.

If you’ve weighed all the pros and cons and decide you need to take some money out of your 401(k) temporarily, set a goal to pay it back as soon as possible. If your plan allows (and not all do), continue contributing to your 401(k) in addition to paying back the loan. At the very least, don’t let your employer’s matching funds go unclaimed. Retirement may seem like a long ways off, but it’ll be even farther for you if you don’t have enough funds saved up.

—For the best rates on CDs, mortgages, savings, credit cards and more, enter your ZIP code at