Saudi Arabia said on Tuesday its economy contracted for the first time in eight years

Saudi Arabia said on Tuesday its economy contracted for the first time in eight years due to painful austerity measures as it announced record spending to stimulate growth.

The OPEC kingpin said gross domestic product for 2017 shrank by 0.5 percent due to a drop in crude production in line with an agreement with major oil producers aimed at boosting prices.

The last time the Saudi economy contracted was in 2009, when GDP fell 2.1 percent after the global financial crisis sent oil prices crashing.

Riyadh also posted a higher-than-expected budget deficit in 2017 and forecast another shortfall next year for the fifth year in a row due to the drop in oil revenues.

It announced an expansionary budget for 2018, projecting the highest spending ever despite low oil prices in a bid to stimulate the sluggish economic, saying it expects the GDP to grow by 2.7 percent.

Spending was projected at 978 billion riyals ($260.8 billion), up 10 percent on 2017 estimates, the Saudi finance ministry said in a statement.

"The 2018 expansionary budget includes a number of new development projects," Crown Prince Mohammed bin Salman, who oversees the economic affairs, said in a statement quoted by the official Saudi Press Agency.

"About 50 percent of the new budget will be financed from non-oil sources," said the powerful prince.

The economic contraction comes as the world's top oil exporter tries to cope with persistent budget deficits that began in 2014 when oil prices plummeted.

In the past four years, Riyadh posted a total of $258 billion of budget deficits, withdrew $240 billion from its reserves and borrowed around $100 billion from domestic and international markets.

The new budget was announced during a cabinet meeting chaired by King Salman who said the country would "continue to decrease its dependence on oil to reach just 50 percent" of total revenues.

The finance ministry said it estimates a budget deficit of $52 billion for 2018.

- Mega projects planned -

The ministry said the budget deficit for 2017 came in at $61.3 billion, or 9.2 percent of GDP, and higher than the expected $53 billion.

The shortfall is still 25 percent lower than the $82 billion posted in the previous year.

King Salman told the cabinet that Saudi Arabia expects to continue posting a deficit through to 2023.

Revenues in 2018 were estimated to be 783 billion riyals ($208.8 billion), up 13 percent on the previous year's projections.

Actual revenues for the current fiscal year rose by a healthy 34 percent compared with 2016 to $185.6 billion due a sharp increase in both oil and non-oil revenues.

Actual non-oil revenues collected in 2017 reached 256 billion riyals ($68.3 billion), a 38 percent rise on the previous year, reflecting the impact of hiking prices and imposing fees.

Riyadh has resorted to a string of austerity measures to contain spending and imposed a variety of subsidy cuts and rises in prices of services.

Prince Mohammed, the architect of the Vision 2030 programme of reforms for a post-oil era, has announced a host of mega projects, including a futuristic megacity with robots and driverless cars, which require about $500 billion in investments.

The cornerstone of the kingdom's economic reforms is an initial public offering of nearly five percent of giant national oil company Aramco planned for next year.

Prince Mohammed last year unveiled his "Vision 2030" programme of economic and social reforms for a post-oil era with the aim to reduce the country's dependence on oil.

The heir to the Saudi throne has been behind stunning decisions to allow women to drive and to lift a 35-year-old ban on cinemas.

Last month, he launched a wide-ranging crackdown on dozens of elites, ostensibly to tackle corruption.

Since 2015, the ultra-conservative Gulf state has introduced a series of price hikes on fuel and electricity.

It has also imposed fees on expats and is preparing to introduce value-added tax in the new year.