Saudi Arabia has tapped international debt markets for just the second time in its history.

The kingdom's sale of Islamic bonds worth $9 billion comes less than six months after the world's biggest oil exporting country tapped global debt markets for the first time by selling $17.5 billion in conventional bonds.

Half of the new Islamic bonds will be repaid in five years, while the remainder will mature in 10 years.

The effort to raise funds from global investors follows a crash in oil prices that turned the kingdom's massive budget surplus into a gaping hole. Just five years ago it was unthinkable that oil-rich Saudi Arabia would need to borrow money from abroad.

Saudi Arabia said in December its budget deficit for this year will reach 198 billion riyals ($53 billion), or 7.7% of its GDP. It planned to narrow the gap by issuing debt and tapping its foreign reserves.

The kingdom's foreign reserves, however, have also taken a hit. The latest data showed them sinking to $514 billion in February from $593 billion the same time last year.

Related: Saudi oil minister: I don't lose sleep over shale

Finding investors to buy Saudi debt doesn't appear to be a problem.

The Saudi press agency said Thursday that the government had received bids worth $33 billion for the new debt. The bonds, known as "sukuk," comply with Shariah or Islamic principles which doesn't allow the payment of interest.

"Saudi Arabia continues to amaze given the performance of the sukuk and the appetite, especially prior to the Easter holiday in Europe and the U.S.," said John Sfakianakis, director of economic research at the Gulf Research Center in Riyadh. "The bond will help alleviate pressure on foreign reserves and deepen the bond issuance program of Saudi Arabia."

Related: Saudi Arabia's giant oil IPO on track for 2018

Last year, the Saudi government revealed a plan, called Vision 2030, to diversify its economy. It also announced a fiscal balance program set to be carried out over three years. The government warned of dire consequences if it did not press on with dramatic austerity measures, including cutting more gas subsides and increasing taxes.