If you ever get into financial trouble, it may be tempting to tap into your retirement plan. However, before you attempt to make a "hardship withdrawal," there are a few things you should know.

Source: 401kcalculator.org via Flickr.

What constitutes a "hardship"?
First of all, it is important to note that retirement plans are not required to allow hardship withdrawals, although many choose to do so. And if a 401(k) or 403(b) plan chooses to allow hardship withdrawals, it is required to provide the specific criteria used to determine a hardship. Meanwhile, a 457(b) plan must contain specific language defining what constitutes an "unforeseen emergency."

According to the IRS' definition, in order for a withdrawal to be made due to hardship, there must be an "immediate and heavy financial need" of the employee or a dependent. This can include medical expenses, housing expenses like a down payment or rental costs to avoid eviction, educational expenses, and funeral or burial costs.

Individual plans will define which of these qualify for a penalty-free hardship withdrawal. For example, one plan might allow hardship withdrawals for medical expenses but may assess a penalty on withdrawals for educational expenses.

Generally, hardship withdrawals can be made penalty-free for unreimbursed medical expenses including health insurance for the unemployed, and they can also be made by account holders who become permanently and totally disabled. You can usually also withdraw money penalty-free to settle any outstanding tax debt. However, home buying and educational expenses are generally subject to the 10% penalty, if they are allowed by the plan at all.

How much can you take out?
For a 401(k), the amount available for a hardship distribution is capped by the total amount of the employee's elective contributions to the plan, reduced by any previous distributions. Regular matching contributions from the employer could be allowed to be taken as a hardship withdrawal.

However, any earnings from your investments are generally not included in the maximum withdrawable amount. As a simplified example, if you have contributed $50,000 to your plan over the years and your employer has matched $25,000 of that, and your account is now worth $100,000 including gains, the maximum you could expect to be allowed to take as a hardship withdrawal is $75,000.

Can I take a hardship distribution from my IRA?
Not really. While it's true that you can take a distribution from your IRA whenever you want, there are no hardship scenarios (like medical bills) that allow you to dodge the IRS' 10% early-withdrawal penalty.

However, there are some other (non-hardship) reasons for which you may be allowed to tap into your IRA early. For example, you are allowed to withdraw money from an IRA penalty-free for qualified higher-education expenses, whether or not you can afford to pay them from other sources. And you can withdraw money from your IRA to put toward the down payment on your first home. There is a $10,000 lifetime maximum, and it can be split into multiple withdrawals.

On the contrary, it might be difficult to take a down payment out of your 401(k). If your plan has a loan provision, the withdrawal will be treated as a loan and not a hardship withdrawal. And if your plan does allow a down payment to be taken as a hardship withdrawal, it will still be subject to the 10% penalty.

Look into other options first
Even if you qualify to take a hardship distribution, it's usually only a good idea if you've exhausted every other source of funding available to you. By the time you consider taking a hardship withdrawal, you should have exhausted your checking and savings accounts, emergency fund, and any non-retirement investment accounts that you may have.

The main reason you should consider a hardship withdrawal to be a last resort is that even a relatively small withdrawal could set your retirement back tremendously. After all, assuming 7% average annual returns, a $10,000 withdrawal when you're 20 years away from retirement could mean about $40,000 less in savings once you retire.

Now, if you legitimately need the money and don't have any other options, a hardship withdrawal could be the best way to go. Just make sure it's absolutely necessary before you do it.