Image: Egg in nest © Brian Hagiwara, Brand X, Corbis

When your banker says no, your 401k says yes.

That is what many employees nationwide seem to think. Publicly traded companies recently have been disclosing how much their workers have borrowed from their retirement accounts -- and loans from 401k's are way up.

In a society already drunk on debt and an economy struggling to recover, people are even hocking their own retirement funds. Most of them are making a mistake.

But, crazy though it might seem, there is a case to be made for borrowing from your 401k account, at least in certain circumstances.

As of Dec. 31, at the retailer Target (TGT, news), total borrowings by employees from their 401k's were up 23% over the year before; at grocery chain Whole Foods Market (WFM, news), 34%; at the homebuilder Pultegroup (PHM, news), 51%; and at Heritage Financial (HFWA, news) a community-bank holding company in Olympia, Wash., 98%.

Altogether, according to retirement analyst Pamela Hess at Aon Hewitt, a consulting firm, 28% of participating workers had borrowed from their 401k's as of the end of 2010, up from 26% in 2009 and an average of around 22% earlier in the decade.

It isn't just lower-income workers who are taking these loans. According to Aon Hewitt, 23% of employees earning between $80,000 and $100,000 have borrowed from their 401k's -- along with 16% of those earning at least $100,000, up from 13% in 2005.

Traditionally, financial advisers have admonished workers never to borrow from a 401k account. That partly is because the money you invest in your 401k is sheltered from income tax, while you must use after-tax dollars to pay back whatever you borrow from the 401k.

The biggest risk: If you leave your job, you must promptly pay off any 401k loan -- usually within 60 days -- or you will owe ordinary-income tax on the remaining principal amount, plus a 10% penalty.

While about 15% of 401k loan balances tend to go into default, at least 75% of the workers who leave their jobs with a 401k loan outstanding end up defaulting, estimates Brigitte Madrian, an economist at the John F. Kennedy School of Government at Harvard University.

One of the most dangerous temptations: There are generally no restrictions on what you can use a 401k loan for. Some 22% of borrowers use the money to pay for college or medical expenses, and 39% use it to consolidate or pay off higher-cost debt, according to research by Stephen Utkus, the director of the Vanguard Center for Retirement Research.

But there is nothing to stop you from spending it on a binge in Cancún, a week at Canyon Ranch spa in Arizona or a pedigreed Tibetan mastiff with a diamond-studded collar.