When Robert B. Keating was an American delegate to the Law of the Sea conference last year, he was occasionally accused of leaking confidential data to mining companies that were working to block the ocean mining treaty. Now Keating's opponents may have sunk his hopes for an ambassadorial post with a well-timed leak of their own.

The result is that Keating's nomination as ambassador to mineral-rich Madagascar, normally not a controversial assignment, has touched off a backstage battle that prompted the Senate Foreign Relations Committee to delay a planned vote on confirming him.

The dispute is over Keating's assurance to Sen. Claiborne Pell (D-R.I.), the committee's ranking minority member, that he did not solicit industry support for an ambassadorship.

Pell asked Keating at his confirmation hearing last month:

"Now, while serving on the Law of the Sea delegation, did you solicit from any individuals in industry for you to be appointed as an ambassador after the negotiations were concluded?"

"Not at all, sir," Keating replied. "I did not, sir."

But the committee recently was given a copy of a July, 1981, message left by Keating for a mining industry representative that reads:

"Being seriously considered for ambassadorship to mineral producing country (prefers S. Africa). Nomination battle now on. Dick Allen has endorsed him already. Would appreciate your endorsement too--send to: Mrs. Wendy Borcherdt, Associate Director, Presidential Personnel, White House, Washington DC, 20500. Phone - 456-6585."

The committee is now investigating allegations that Keating asked a number of industry officials to support him for an ambassadorship, and the panel plans to question Keating privately about the issue.

At the request of Pell and other Democratic members, Chairman Charles H. Percy (R-Ill.) canceled a scheduled vote on Keating's nomination Tuesday morning and has deferred the matter for at least several days.

Keating could not be reached for comment this week.

Keating, 59, has been vice president of Pure Water Systems Inc., worked as a self-employed consultant and directed road projects in Zaire in the early 1970s.

When Ronald Reagan was governor of California, he named Keating to head a technical cooperation program with Chile.

Senate sources said the debate over Keating's assignment to a small East African nation has given his opponents a chance to replay the long-running debate over the Law of the Sea treaty, which the United States refused to sign last year.

President Reagan has said the treaty, which most other nations have endorsed, does not adequately protect American companies' advanced plans for undersea mining.

The committee has questioned why Keating, while working as a treaty consultant for the Defense Department, also lobbied privately against the treaty.

The panel has copies of private letters in which Keating told industry executives last year that he opposed the treaty, and sources say he also helped arrange a White House meeting for mining company opponents.

When asked about Keating's role during the Law of the Sea conference, Leigh S. Ratiner, who was the chief U.S. negotiator, said, "I did not believe Keating had a legitimate function to perform on the delegation. I felt we shouldn't have him. He maintained close and frequent relations with members of the ocean mining industry."

Added one member of the delegation: "The reason we lost that treaty is that Keating would relay information to the industry and the industry would call the White House. The industry would get information on our negotiating position within minutes after it came out of the typewriter."

One person involved in the mining industry, who asked not to be identified, said Keating has called him several times over the last two years.

"He'd say he would love to go back to Africa, to be an ambassador, and that he'd really appreciate our support," this source said. "There's no question he solicited me. Everyone I know got solicited by him. I felt pressured by it."