China's benchmark Shanghai Composite index gained nearly 6 percent on Thursday, after falling sharply the two days before.

More than 1,400 companies — representing a majority of all companies traded on the mainland's two major exchanges — have halted trading in an effort to stop the previous days' slide.

On Wednesday, Chinese officials banned companies' major shareholders from selling shares for six months, which might have contributed to Thursday's rally.

Over the past year, the market surged due to borrowed money

Between June 2014 and June 2015, China's Shanghai Composite index rose by 150 percent. A big reason for the stock market rally was that a lot more people started buying stocks with borrowed money. This practice, known as "trading on margin," used to be strictly regulated by the Chinese government. But as the Financial Times explains, Chinese authorities have gradually relaxed these requirements over the past five years.

During this period, the amount of officially sanctioned margin trading in the Chinese stock market ballooned from 403 billion yuan to 2.2 trillion yuan. Experts estimated that another 2 trillion yuan or so of borrowed money has flowed into the markets using vehicles designed to skirt official limits on margin trading.

The surge in stock prices alarmed Chinese authorities, and so earlier this year they took steps to rein in margin trading and other forms of leveraged investing. In January, they raised the minimum amount of cash needed to trade on margin, once again restricting the practice to wealthier investors. They also punished a dozen companies for failing to enforce rules on margin trades. The government cracked down on vehicles designed to skirt the margin trading rules in April.

The government's toughest measures came on June 12, when China's securities regulator announced a new limit on the total amount of margin lending stock brokers could do, while also reiterating the curbs on illicit margin trading.

The stock market has been in free fall ever since.

Government efforts to prop up the market haven't worked very well

About a week ago, Chinese policymakers grew concerned that these efforts to rein in stock market speculation were working too well. Now that stock prices have been plummeting, the government is trying to prop them back up.

On Saturday, 21 major Chinese brokerages made a coordinated announcement, pledging to purchase $120 billion yuan worth of Chinese stocks to help stabilize the market. Chinese brokers vowed to keep buying stocks until the Shanghai index had risen to 4,500. Also, 28 privately held companies canceled plans to hold initial public offerings that could have drained capital away from companies that were already publicly traded. It's widely suspected that these moves were made at the behest of the Chinese government.

On Sunday, China's central bank also announced it would inject cash into the China Securities Finance Corp, a state-owned company that finances margin trading. In other words, the Chinese government is printing money to finance leveraged stock investment.

And in the past three days, a growing number of companies have announced that they were suspending trading altogether, in an apparent bid to prevent further declines.

But these measures didn't work very well. After modest gains on Monday, the Shanghai index fell 1.3 percent on Tuesday and lost another 5.9 percent on Wednesday.

On Wednesday afternoon, in its most drastic step yet, Chinese authorities banned major shareholders — those with more than 5 percent of a company's shares, as well as senior executives and board members — from selling their shares for a period of six months.

On Thursday, stocks rose. The Shanghai Composite closed at 3,709, up 5.7 percent from Wednesday's closing price, but still down 28 percent from the June 12 high.