A whopping 96% of Americans have experienced at least one serious "income shock," or an emergency that caused a drop of 10% or more in their pay. These shocks typically owe to a job loss or health scare, and when they happen, you need to be prepared with an emergency fund.

The problem, though, is that a good number of Americans don't have nearly enough money set aside to cover a financial emergency like this. In fact, 69% of Americans have less than $1,000 in their bank account -- and 34% of them have no money at all saved.

two men talking about finances

Image source: Getty Images.

So when an emergency does occur, how can you pay for it if you have no savings? You could take out a personal loan, but depending on the health of your credit, you could be paying upwards of 20% in interest (or you may not even be eligible for a loan at all).

This is when many people turn to their 401(k)s, thinking that borrowing a few hundred (or thousand) dollars couldn't hurt. But is it ever OK to borrow from your retirement fund?

Most experts advise against it

Many argue that you should never, ever borrow from your 401(k), because your retirement savings should be sacred. After all, a day will come when you'll rely on them to make ends meet, and a 401(k) loan can put a bigger dent in those savings than you may realize.

While the interest you pay on 401(k) loans goes back into your account -- which means you're repaying yourself, rather than a lender -- you also have to consider opportunity cost. Assuming your investments are earning an annual 7% rate of return, that's a lot of money you're potentially losing just by withdrawing your savings. Additionally, many plans won't let you contribute to your 401(k) until you've paid back your loan. While loan payments still go back into your 401(k), those payments don't come from pre-tax dollars like regular 401(k) contributions do, so you're missing out on the tax break. 

Say, for example, you have $35,000 in your 401(k) and take out a loan of $5,000 that you repay in one year. Assume that the remaining $30,000 in your 401(k) is earning a rate of return of 7% each year, and you're paying an interest rate of 4% on your loan. For simplicity's sake, also assume that you don't make any additional contributions. Here's a side-by-side comparison of how much you'd have in your retirement fund if you hadn't taken that loan compared to how much you have with the loan:

Number of Years 401(k) Balance Without Loan 401(k) Balance With Loan
0 (Starting Point) $35,000 $30,000
1 $37,450 $35,200
5 $49,089 $42,601
10 $68,850 $59,750
20 $135,439 $117,537

So while the loan isn't a retirement-breaker, that $5,000 loan would end up costing you about $18,000 over 20 years. All of that said, however, sometimes -- if you have exhausted all other options -- it is OK to borrow from your 401(k).

When (and how) to borrow from your 401(k)

The best time to borrow from your 401(k) is when it's only a short-term loan (meaning you'll be able to pay it back in less than a year) and you need it for a real emergency. You're also not allowed to borrow more than $50,000 (or 50% of the amount in your account -- whichever is less), so if you're looking to borrow more than that, your 401(k) is not the answer.

A 401(k) loan is also a good choice if you need money immediately, because there's no lengthy application process involved. You can usually just visit your plan's website, select how much you need, and have the check in your hands within a couple of days.

Before taking out a 401(k) loan, look at your other options and see which one will cause you to lose the least amount of money. If your only other option is to take out a payday loan and end up paying 400% in annual interest, all of a sudden borrowing from your 401(k) doesn't look so bad.

Although borrowing from your 401(k) is not ideal, emergencies happen. And if you're low on savings, can't get a traditional loan, or would end up paying way too much in interest with a traditional loan, a 401(k) loan may be a good idea. As long as you pay it back quickly, use the money responsibly, and don't make a habit of taping your retirement savings, you'll soon be right back on track. And once you are, start building up those emergency savings immediately so you can leave your 401(k) untouched the next time you need money in a hurry.