How often have you heard that you should fund (and max out) your Roth IRA?

This is really common advice, especially if you’re in your 20s and 30s and just starting to save and invest for major goals like retirement. And it can be good advice, too!

A Roth IRA helps you save money for retirement that you can withdraw tax-free. It’s a great way to diversify the tax benefits of your retirement accounts (since accounts like 401(k)s work the other way around: you get a tax break when you contribute today, but you need to pay taxes on your withdrawals on the future).

While you should plan to use your Roth IRA as it’s meant to be — as a retirement savings tool — emergencies do come up and life happens. It’s important to understand how and when you might want to use your Roth as a tool to achieve a different financial goal.

Roth IRAs Can Fund More Than Just Retirement

If you meet certain criteria, you can withdraw and use money in your Roth for more than just retirement. But first, you need to know the rules so you can make smart decisions on when it makes sense to break them.

Here’s the basic rundown on Roths:

  • You can contribute up to $5,500 per year (as of 2017) if you’re under 50. You can contribute up to $6,500 if you’re over 50.
  • You can contribute even if you have an existing plan that you contribute to through your employer.
  • You can withdraw your contributions at any time without penalty.
  • You can withdraw your earnings under certain circumstances, and if you’ve owned your Roth account for at least 5 years.
  • Nonqualified withdrawals will result in taxes and penalty fees.

This is why it’s really important to know exactly when you can use money in your Roth. If you just take out money and use it flippantly, you will pay a 10% penalty and the money could be subject to taxes, too.

Yes, You Can Take Out Your Own Contributions — But Think Twice Before You Do

You can withdraw the money you contribute to your Roth IRA at any time without any penalty. In most cases, this is not a smart money move.

When you withdraw those funds, you not only set yourself back on your retirement savings, but you lose the opportunity to let time and compound interest go to work for you on that money.

Unless you have very good reason to withdraw your contributions, leave them in your account. Nope, buying a new car, going on vacation, or using that money to pay off your maxed-out credit card (so you can go on a new shopping spree) are not good enough reasons!

One strategic way you could use your Roth is to treat it like an emergency fund. If you have very few financial responsibilities and have other sources of cash (like a small buffer in your checking account), you might want to use your Roth contributions as your emergency savings.

This allows you to invest the cash you hope you don’t need to use, since it’s for emergencies only. That will give you an opportunity to grow that money over time — but if you need it, you can withdraw the contributions.

Note that you need to be okay with risking the money in your “emergency fund” if you stash it in your Roth. All investments come with risk, and there’s a chance you might need some of your contributions when the market is low.

That exposes you to losses, whereas a liquid savings account would keep that money much safer. If you’re considering using your Roth this way, be sure to talk to your financial advisor before making any withdrawals and to think through all your options to ensure this makes sense for you.

Now that you’ve been properly warned against mindlessly mining your Roth IRA for cash when you want to do some extra spending (it’s worth repeating: do not do this!), let’s look at some situations where using your Roth to fund more than just retirement could work for you.

When You Can Withdraw from Your Roth IRA Without Penalty

If you want to withdraw both your own contributions and some of the earnings in your Roth, there are only a few circumstances in which you can do so without incurring a 10% penalty and taxes:

Inherited Roth IRA Assets: If the owner of a Roth IRA dies and you’re the beneficiary, you won’t pay penalties or taxes if you withdraw any funds if the account has been open for a minimum of five years. If the account is less than five years old, it will be taxed as income but has no penalty fees.

Higher Education Expenses: You can use funds from your Roth IRA, penalty-free, for higher education expenses (like tuition, books, and room and board). If the account is at least five years old, you won’t pay taxes, either.

The amount you take from the account can’t go over what the education expenses are, and this exception only applies to qualified colleges, universities, and vocational schools that are eligible for federal financial aid. Pay close attention to IRS rules about qualifying schools and expenses.

Unreimbursed Medical Expenses Over 10% of Adjusted Gross Income: You can pull from your Roth to cover extra medical expenses (that your insurance doesn’t cover) that go over 10% of your adjusted gross income.

This money is penalty-free and not subject to income tax as long as the account is at least five years old. You need to pay income tax on any earnings used that are less than five years old, but you won’t pay a penalty.

Medical Insurance Payments: Say you lost your job tomorrow. You still need to pay for your health insurance, even if you’re unemployed. A Roth can help cover those premium costs.

You need to file for unemployment and receive unemployment payments for at least 12 consecutive weeks first. Any funds you take out of your Roth need to be used the same or following year as the unemployment payments, too.

Disability: If you become disabled before the age of 59 and a half, you can use Roth IRA funds without penalty. You’ll need to provide proof that you can’t earn a living due to physical or mental disability and a doctor must confirm a terminal or permanent condition.

First-Time Homeowner: If your Roth has been opened for at least five years, you withdraw $10,000 or less, and you use those funds directly toward buying a home (meaning, you have to use the money for a down payment, closing costs, and so on), then you can use your Roth to fund your first home purchase.

Even if you’ve owned a home before, you may be able to use your Roth toward a new home purchase — you just can’t have owned a house in the 2 years prior to buying the house you’re considering now.

(This applies to your spouse, too, if you’re married!)

Military Reservists Distributions: People who meet IRS qualified reservist status are allowed to withdraw funds from their Roth accounts without penalty. There are several qualifying rules that must be met by the IRS for this exception, so be sure to read through and make sure you qualify under these terms.

There are many different ways (and reasons) you could use your Roth IRA funds without incurring any penalties. but that doesn’t mean this account should be the go-to resource when you feel like you need cash.

Again, talk to a financial planner to help you evaluate all your options — especially if you suddenly come into money you didn’t expect to have.

It might make sense to withdraw the funds from your Roth and use them elsewhere, but you need to think through those next steps strategically and in the context of your entire financial plan.