When you’re sitting there, unemployed (or underemployed), trying to hold on to your house and keep food on the table somehow, you probably don’t really care that the money in your 401(k) was intended for your retirement. In fact, it’s likely you’re feeling a little desperate and want to do anything you can, no matter what, just to stay in place.

Similarly, if you’re in a financial bind and can’t get any loans, you may notice what seems like a gold mine in the form of your retirement accounts.

Whatever the reason that you’re looking to access your retirement accounts early, you may be wondering how you can do so without getting your hand slapped.

What are the best ways to tap into your retirement funds—and avoid the IRS and state early withdrawal penalties?

1) If you’re under age 59½ with a lot of money in your retirement accounts (we’re talking $500,000 or more), you can annuitize your withdrawals. That means that over your life expectancy, you may take substantially equal draws each year. Winners of the IPO lottery with millions in their retirement accounts can do this at any age. (This is called the code 72(t) exception—see Bankrate’s calculator.)

2) If you are under age 59 ½ and your money is in anything but an IRA, you will want to do some planning first. Decide how much of your retirement funds you’re going to need to use, then roll it into an IRA. The rollover will be tax-free, and once the money is in the IRA, you can avoid early withdrawal penalties if you use it for higher education costs, health insurance, or any medical expenses in excess of 7.5 percent of your adjusted gross income. The IRS explains how this works.

3) Better yet, don’t take distributions at all—take loans. Folks who are presently employed and who have a 401(k) may be permitted to borrow from it. The law allows you to borrow up to 50 percent of the account, up to $50,000, if your plan allows loans.

Do you have an older 401(k) with more money in it than your current one? Ask your administrator if you are allowed to roll your old account into your new one. That will make these loans possible.

You’re unemployed now? No problem. Start a business and set up a solo-401(k) for yourself—and for your spouse, too, if your spouse has an old 401(k). Then roll over your old accounts into the new one. Now, borrow the funds. Just make sure not to close the business before paying the funds back.

In either case, when you borrow, there will be no taxes—and you’ll be paying yourself back.

The added benefit of starting your own business in order to borrow your own money is that you just might turn your life around. It’s amazing what happens when you have something about which to be passionate.

Eva Rosenberg, EA, is the publisher of TaxMama.com®, where your tax questions are answered. She teaches tax professionals how to represent you when you have tax problems. She is the author of several books and e-books, including Small Business Taxes Made Easy. Follow her on Twitter: @TaxMama