In a move with implications for gay-rights advocates and for millions of people who use computer online services, both the Navy and America Online have reached settlements with a highly decorated sailor who was investigated by the Navy after he posted a message in which he described himself as "gay."

Under the Navy agreement, Master Chief Petty Officer Timothy R. McVeigh, 36, will retire from the military with full benefits and with tens of thousands of dollars to pay his legal fees.The Navy had originally sought to discharge McVeigh without benefits, despite 18 years of otherwise unblemished service, after he posted a note on the online computer service in which he identified himself as "Tim," whose marital status was "gay" and whose e-mail address was "Boysrch."

The Navy's settlement with McVeigh, who is no relation to the man convicted of bombing the Alfred P. Murrah Federal Building in Oklahoma City, was being announced Friday.

In a separate settlement, America Online has apologized to McVeigh for violating his privacy and has agreed to pay him damages. Both sides agreed not to reveal the amount of money paid to McVeigh.

"I'm happy that this case has been resolved on my terms," McVeigh said Thursday from his home in Honolulu.