Gen. John William Vessey Jr., chairman of the Joint Chiefs of Staff and the last four-star combat veteran from World War II on active duty, retired in character yesterday as he bade farewell to 46 years of life as a soldier: "Thanks. Thanks, troops."

The 63-year-old Vessey, who enlisted in the Minnesota National Guard as a 17-year-old private in 1939 and received a battlefield commission while fighting on the beachhead of Anzio, Italy, in 1944, always considered himself a mud soldier. He saved his final words for those serving in that capacity.

A smiling President Reagan looked on as Vessey bade farewell in a cavernous hangar at Andrews Air Force Base filled with dignitaries, well-wishers and ceremonial troops. Before Vessey took the microphone to make his last official remarks, Reagan saluted the soldier who had served as his primary military adviser the last four years.

"Gen. Vessey will be remembered for many things," Reagan said, but one accomplishment stands above all the rest: "Jack Vessey always remembered the soldiers in the ranks. He understood those soldiers are the backbone of any army. He noticed them, spoke to them, looked out for them. Jack Vessey never forgot what it was like to be an enlisted man, to be just a G.I."

Defense Secretary Caspar W. Weinberger, a World War II Army veteran, saluted Vessey's "unshakable integrity" and "wisdom with vision." But he said the general's most valued attribute in the Pentagon's bureaucratic forest was his "great common sense, the soldier's humor, the soldier's insight."

Vessey will be succeeded today by Adm. William J. Crowe Jr., former U.S. commander in the Pacific.

Shortly after Vessey was named by Reagan to the military's top job on June 18, 1982, the general called a meeting of top officers who would serve with him at the Pentagon. He told them, according to participants, that if they did not believe in miracles, one was standing in front of them -- himself. He said he never expected to end up as chairman of the Joint Chiefs.

The general went on, participants said, to lambaste the news media and warn officers to avoid friendships with reporters. He blamed the media for the firing of Maj. Gen. Jack K. Singlaub, who served as Vessey's deputy in Korea. Then-President Jimmy Carter relieved Singlaub after he ignored a warning and spoke out a second time against the administration's plan to withdraw some U.S. troops from Korea.

Vessey kept his distance from the media during most of his four years and thus had a low profile outside the military establishment. But inside the military he won praise for bringing dignity and honor to the chief's job, for pulling the four services together and for resisting attempts to make sweeping changes in the structure of the Joint Chiefs of Staff.

Reagan rejected advice from Vessey and the other chiefs, who warned against sending Marines into Lebanon a second time. The Marines subsequently met disaster when a terrorist drove a pickup truck full of explosives into their compound at the Beirut airport in October 1983, detonating the load and killing 241 servicemen. The Marines were withdrawn.

The other two big military operations conducted on Vessey's watch were the invasion of Grenada and the bombing of Lebanon in December 1983. The Grenada operation rescued Americans on the island but brought criticism of serious miscues among the four services involved. The December bombing was also criticized for being badly flawed in timing and execution. Two bombers were lost.

Otherwise, Vessey's four years as chairman of the Joint Chiefs were tranquil compared with his nine predecessors. He had no fractious Vietnam war nor deep cuts in the budgets of the armed services. The volunteer military attracted soldiers and sailors considered more motivated and intelligent than at any time since the draft was abolished. Congress and the president also provided record amounts of money for peacetime.

Vessey, as chairman, was not formally in the military chain of command. Instead he was limited to recommending courses of action and transmitting the president's orders from the secretary of defense to theater commanders around the world. There are numerous proposals in Congress to give the chairman more power. But Vessey's view was that the organizational structure of the chiefs is not broken and therefore does not require fixing.

Vessey, in his farewell remarks, chided Congress for "dabbling too deeply" in defense matters and said the lawmakers will waste more money than they will save by trying to reform the Pentagon. "Stop dabbling," Vessey pleaded, "and judge us by broad objectives" set down for the military.

The general and his wife, Avis, left Washington shortly after the retirement ceremony for their lakefront home in Garrison, Minn., their 29th and -- as Avis Vessey has indicated -- final move.