Sen. John C. Stennis (D-Miss.), a courtly conservative who has been a senator longer than all but one man, announced yesterday that he will not run for a seventh term next year because his age and health would prevent him from giving "my best effort through another six-year term."

"My heart says yes, run again, but my best judgment says no," Stennis said in a statement.

Stennis, 86, who lost a leg to cancer in 1984, made his statement just before surgery for a prostate gland problem at Walter Reed Army Medical Center yesterday. Following the surgery, his office said, "There was no evidence of cancer, but tissue specimens are being routinely examined by pathologists."

Stennis helped lead the South through a series of epic but losing filibusters against civil rights legislation in the 1950s and 1960s, then survived a nearly fatal gunshot wound in a holdup and numerous illnesses to spend four decades in the Senate, longer than anyone except the late Carl Hayden of Arizona.

Stennis was a hawk who used his 11 years as Armed Services Committee chairman to support the Vietnam war and to consistently champion a strong military. He also gained a reputation for integrity that his colleagues often could not equal. He wrote the Senate's first code of ethics and was chairman of the ethics committee that censured former senator Thomas Dodd (D-Conn.) for mixing campaign and personal funds.

His decision ignited a scramble among his possible successors and complicated the Democrats' effort to retain their 54-to-46 control of the Senate. Three other senators have announced their retirements -- William Proxmire (D-Wis.), Robert Stafford (R-Vt.) and Paul S. Trible (R-Va.).

The most likely Republican prospects for Stennis' seat are Rep. Trent Lott, the House minority whip; Haley Barbour, Stennis' opponent in 1982 and a former deputy political director in the Reagan White House; and former House member Webb Franklin, who lost his Mississippi Delta district seat last year.

Lott and Barbour indicated earlier that they would be interested in the Senate race but that they would not run against Stennis. Barbour said he would decide after the Mississippi gubernatorial election in November; Lott would not say how soon he will decide.

On the Democratic side, Rep. Wayne Dowdy immediately announced that "I will be a candidate for the U.S. Senate," and former governor William Waller said yesterday that he would "seriously consider it."

Another Democrat, Secretary of State Dick Molpus, who said earlier that he was "very interested" in making the race but would not run against Stennis, indicated that he would probably make his decision in about two weeks. Other possible Democratic candidates are former representative David Bowen and Gov. William Allain, according to state chairman Steven Patterson.

Lott also has ambitions to be House minority leader. Political observers believe, however, that another leadership candidate, Rep. Richard Cheney (R-Wyo.), may have gained on Lott because of his performance during the Iran-contra hearings and that this could bear on Lott's decision.

There was a note of regret in Stennis' statement.

"I greatly regret leaving the Senate where it is my high privilege to represent the people of Mississippi whom I dearly love and respect but age and health control," he said. "Still, I am forced to recognize that another six-year term in the Senate would require me to promise to continue my work here through age 93. Common sense dictates that I cannot be confident of being physically able to continue to give my best effort through another six-year term and my doctors confirm my judgment."

In addition to losing his leg, Stennis suffered nearly fatal gunshot wounds in 1973 when he was mugged on the street near his home in the District of Columbia and has undergone heart surgery.

Stennis won a special election in 1947 after the death of outspoken segregationist Theo G. Bilbo. As president pro tempore of the Senate, he is third in line for the presidency and when he leaves office at the end of January 1989, he will have been a senator 41 years and two months, just eight months short of the Senate longevity record of Hayden, who served 41 years and 10 months.

Stennis beat Barbour by 64 percent to 36 percent in 1982 and was unopposed in the general election in 1976.

"John Stennis brought to his office an unequaled sense of personal integrity and responsible patriotism," said Senate Majority Leader Robert C. Byrd (D-W.Va.). "His voice and opinion were major influences in helping his colleagues make their own decision, recognizing as they did his wisdom, decency and practical experience."