Here's a personal finance rule you can break — with reservations: Taking a loan from your 401(k) plan.
Aside from your house, your workplace retirement plan likely makes up the largest chunk of your overall wealth. The average 401(k) balance in the fourth quarter of 2016 hit an all-time high of $92,500, according to data from Fidelity Investments.
In a perfect world, you'd want to let your account ride as long as it can, taking advantage of market cycles over time and steady deferrals from your pay each week.
However, certain emergencies and long-term planning goals call for the more drastic step of borrowing from your 401(k), as was the case for Greg Walton.
The 32-year-old IT support engineer at the Massachusetts Institute of Technology borrowed $7,000 from his 401(k) in order to pay off a student loan with a higher interest rate and which had gone into default at one point.
Walton is repaying the loan directly from his paycheck.
"Plan participants understand that the money is sacrosanct, but they may find themselves in a situation where the 401(k) is the largest source of capital they have," said James A. Cox, financial advisor at Harris Financial Group in Richmond, Virginia.
Here's how to borrow from your 401(k) without ending up with a big tax bill.
Loans vs. withdrawals
Retirement plan loans are different from withdrawals and hardship distributions.
Depending on whether your plan permits borrowing, you're generally allowed to take up to 50 percent of your vested account balance to a max of $50,000 — whichever is less. You have five years to repay the loan.
That's different from simply withdrawing money. In that case, your plan administrator will withhold 20 percent of the amount to cover income taxes and you'll trigger a 10 percent penalty if you're under age 59½.
Finally, a "hardship distribution" is what happens when an employee pulls his or her own contributions to cover what the IRS describes as an "unforeseeable emergency."
These distributions are included in your gross annual income and may be subject to additional taxes, but they aren't repaid to the plan. This means they permanently lower your account balance at work.
When to borrow
Once you pull money out of your plan, those dollars no longer benefit from long-term market returns.
Even your boss wants you to keep your hands off your retirement plan savings.
That said, here are three extreme cases that may warrant a 401(k) loan.
You have an immediate emergency. "Say that you need to meet the deductible on your high-deductible health-care plan, and you have no money in your health savings account," said Aaron Pottichen, president of retirement services at CLS Partners in Austin, Texas.
He is referring to the tax-advantaged savings account that individuals may use to cover qualified medical expenses. It's also known as an HSA.
You have an urgent cash need, but your credit precludes you from obtaining a competitive interest rate. Ask yourself what you can repay in five years.
"From an interest-rate standpoint, [a 401(k) loan] can help, but be careful not to max out your term," said Tyler Harrison, managing member of Efficient Plan in Denton, Texas.
You need to pay off high-interest debt that's hampering your long-term financial goals. This is the case if the interest rate on your 401(k) is lower than what your creditor is offering you.
"If you're in 'pay down debt mode,' it's all about what's your cheapest interest rate and how fast can you get the debt down," said Pottichen.
Avoid these pitfalls
In the worst of scenarios, you'll borrow from your retirement plan, fail to repay it and end up with your finances in even worse shape.
Don't borrow if you're planning on leaving. Whether you quit your job or you're fired, you may need to repay the whole balance of your loan within 60 days or else the amount borrowed is considered a taxable distribution.
Don't ignore your debt-to-income ratio. Treat your plan loan the way you would any other extension of credit. Including your 401(k) loan repayment and other liabilities, your monthly debt service shouldn't exceed 40 percent of your gross monthly income, said Harrison. This is your debt-to-income ratio.
Don't blow off your plan's rules for loans. A 2016 study from Aon Hewitt revealed that six in 10 employers have said they'd take steps to curtail the leakage of assets from retirement plans. Those actions include limiting the number of loans available or the amount of money that's eligible for borrowing.
Plans can also establish their own repayment and schedules, which you'll need to follow.
"When you take a 401(k) loan, it comes out of payroll and reduces your take home pay," said Cox. "Either you follow the payment schedule or you fully remit the balance due."
More From CNBC