Ariel Sharon, the most controversial military leader in Israel's history, has signed a contract with Simon and Schuster to write his autobiography, and will cooperate in a second book dealing with his libel suit against Time magazine.

The Time book, due in fall 1986, will be written by Sharon's former spokesman, Uri Dan. The book will almost surely be laudatory of its subject. When Sharon was defense minister, Dan was his press secretary, and during the libel trial in New York last winter, Dan was almost constantly at Sharon's side, often acting as his unofficial spokesman. Dan is also a well-known journalist in Israel, having worked both for Israeli papers and the New York Post.

The autobiography will be written by Sharon himself. So far, Simon and Schuster has not set a date for publication.

The two book contracts end a two-year publishing saga. Sharon first began shopping for a publisher for an autobiography after he led the Israeli invasion of Lebanon in 1982. Random House was not interested, but its archrival Simon and Schuster was, and nearly signed a one-book contract for about $200,000. But those negotiations fell apart.

With a new agent, and after the libel suit against Time heightened interest in the subject, Sharon went back to Simon and Schuster for further talks. Simon and Schuster editor in chief Michael Korda confirmed the signing yesterday, but would not disclose the terms.

Sharon sued Time for $50 million in damages for publishing an erroneous paragraph about him. In its Feb. 21, 1983, issue, Time wrote that a secret appendix of the Israeli investigation into the massacre of Palestinian refugees in refugee camps of West Beirut revealed that Sharon had once mentioned the need for "revenge."

The jury ruled that Time had not acted with "reckless disregard for the truth" and did not award any damages, but Sharon supporters claimed victory, saying that by judging the paragraph untrue, the jury vindicated Sharon's conduct as Israel's defense minister during the war in Lebanon.

Sharon is now minister of industry and trade in Israel's national-unity government. He was a close ally of former prime minister Menachem Begin and remains a member of the conservative Likud party.

Sharon planned and carried out military operations in all of Israel's major wars, earning him the nickname from his troops "The Lion of the Desert."