Image copyright Getty Images Image caption Many investors have been tempted by the combination of swanky apartments and luxury lifestyle

Homebuyers in Dubai can choose from an apartment block with interiors encrusted in shiny crystals or multimillion-dollar villas on a man-made island. Is investing in these desert dwellings like playing on quicksand or has the city-state learnt the lessons of its 2008 property crash when it nearly went bust? The BBC's Mark Lobel investigates.

There are countless reasons why people still buy in Dubai.

It is the perfect tax haven for rich foreigners.

Long-term resident and British developer Andrew Lemon says: "Sun, fun, no tax still applies - and it's a big draw." He has noticed some people prefer it to Monaco to flee tax laws in France.

Dubai is also a safe haven for regional investors in a stormy Middle East.

Lebanese-born businesswoman Nejoud Nasr left Beirut for Jordan in 1983 during the civil war. She feels Dubai is now the safest place in the region for a family, with the rest of the Middle East "marked by a lot of political instability".

Blend of East and West

For wealthy Asians, it is a close-by, comfortable, retirement village.

For Indian former private banker Ranjita Balasubramaniam, Dubai ticks a lot of boxes.

She likes its blend of East and West, wants to settle in the Emirates and employ domestic staff to help her at home.

"We have always had help around us. Dubai allows you the ability to have that," she said.

A surge in house prices and sales since 2013 suggests confidence is returning to Dubai's real estate sector after its disastrous past.

But what went wrong and has anything actually changed?

Musical chairs

When foreigners were permitted to buy in 2002, it helped turn the obscure fishing village into a global hub.

Estate agents who watched the property boom over the next six years said it was like the Wild West because the regulations were so lax.

Speculators made a fast buck by selling off-plan properties for a large profit within weeks of their initial investment - with no intention of ever living there.

Linda Mahoney, one of Dubai's first Western estate agents, described it as a game of musical chairs.

"It went on and on and on and there was always another place to sit… In June 2008 the music stopped and the chair wasn't there."

Image caption Investment apartments are large and can be sumptuously appointed

Once the global credit crisis of 2007 spread to Dubai a year later, lending dried up, many foreign investors left and confidence in the emirate's overinflated real estate market was shattered.

It was a bloody period as property prices fell from between a third to under half of their previous value in months. The stock market fell 70% and thousands of mostly Asian labourers were sent back home.

Huge housing projects were stalled or scrapped.

Before the crash, investors piled into one large, well-located apartment block named after Hanover Square in the West End of London.

The Dubai development is 15 minutes from a golf course and the sea and half an hour from the busiest international airport in the world.

In 2007 investors put down tens of thousands of dollars but have so far received nothing.

Its developer ACW Holdings said it is "rapidly nearing completion". When I visited the site it looked about 80% ready. It should have been completed six years ago.

Others have been less lucky and lost everything on cancelled projects.

Surreally crafted

Another effect of the financial crisis was the alarming exposure of Dubai's huge, outstanding debt at the time.

To understand it, I took a boat trip around the iconic Palm Jumeirah to see the eye-watering multimillion dollar villas on the man-made island.

They represent a life of poolside and yacht-filled luxury surreally crafted in the middle of the desert.

Yet in 2008 the ambitious island project, along with two others also built by the government-owned developer Nakheel, nearly brought Dubai to the brink of defaulting on its debt because so much had been borrowed to make it happen.

Only a $20bn lifeline from Dubai's oil-rich neighbour, Abu Dhabi, saved it from going bust.

Half the money was used to bail out Nakheel, which brought in a new man to steer it to calmer waters.

The Nakheel chairman Ali Rashid Lootah told me the company had a remaining $1.2bn of debt that he expects to clear by August next year.

However, other state-related entities are holding $140bn worth of debt, according to the International Monetary Fund, which it believes is a worrying amount if another downturn occurs.

But real-estate regulations have improved.

Unpredictable

The government has discouraged speculators by doubling a transaction tax and there are rules to help investors seek compensation if a project is cancelled.

The combination of the new rules and weaker economic conditions globally, which affect investment in Dubai as foreigners make up around 90% of its population, means the market is cooling. Property prices have dropped about 5% so far this year.

Yet many in the industry do not rule out another bubble forming - as Dubai remains unpredictable.

Sunil Jaiswal organised the first international property show dedicated to Dubai. He told me that the question he gets asked most in any show is whether the market will crash.

"Right now the market is quite stable in Dubai. We haven't seen excessive growth... Will the market crash? Of course it will. Maybe it's three months away. I don't know," Mr Jaiswal said.

Ms Mahoney also anticipates there may be an overheating of the market as Dubai's hosting of the Expo 2020 international trade fair nears.

Image copyright Getty Images Image caption Emaar, a leading property developer in the UAE, also built the Burj Khalifa, the world's tallest building

"By 2016-17 I think that the government will probably have to be careful and watch out for another bubble. That's my feeling," she said.

At the top of one of Dubai's grandest designs, the Burj Khalifa, the tallest building on Earth, I met the man whose company Emaar built it and which has sold tens of thousands of properties in Dubai.

Storm

Mohamed Alabbar is one of the emirate's richest and most politically well-connected developers.

He said the current dip in the market - which he prefers to call "a nice adjustment" - may last for up to two years and has made the city "much more affordable".

It ties in nicely with his belief that Dubai could become the New York or London of the Middle East by rivalling the amenities and business facilities of the global cities while offering a better location and cost.

"The region around us, with two billion people, they are all looking for an interesting hub where you can live, where you can invest, where it is safe, where it is prosperous, clean and progressive," he said.

He did concede that more needs to be done by the government to address the plight of badly paid and poorly housed construction workers, who typically earn between $130 and $380 a month with free board and lodging in often cramped conditions.

Last month, a rare protest was held by hundreds of South Asian labourers on a development of Mr Alabbar's near the Burj Khalifa, despite a ban on protests in the emirate.

The labourers were concerned that their pay was dramatically down after a cut in overtime work. Mr Alabbar's company, Emaar, said the contractors employing the workers had been given clear guidelines to carry out their duties properly and resolve the matter quickly.

There is also uncertainty over how the region will cope with low oil prices. Although Dubai is not directly reliant on oil revenues, many of its lenders and investors are.

So there are many unknowns on which Dubai's future rests. However exciting an opportunity it may appear, estate agents recommend that only long-term investors who can weather a financial storm should consider buying in Dubai.

Even then, any investment should be handled with care.