The Pentagon said yesterday that for the first time since World War II it will have the power to open overseas military mail, but only if a soldier is suspected of mailing drugs, guns or other contraband.

A Pentagon attorney who negotiated the agreement with the U.S. Postal Service stressed that there will no wholesale opening of letters mailed by military personnel.

The idea, he said, is to zero in on those suspected of using the military's mail service to traffic in drugs.

"They've been getting a free ride on our own mail service," the attorney said.

A Defense Department attorney would have to obtain permission from a commanding officer before a G.I.'s mail could be opened, just as a U.S. attorney must receive advance approval from a federal judge before opening civilian mail, the Pentagon official said.

"We don't have federal judges to go to overseas," the Defense Department attorney said in explaining the new arrangement involving commanding officers.

The proposal first was announced in the Federal Register April 6. It has been amended in the light of reaction since.

It will appear in revised form in the Federal Register within the next two weeks, according to the Pentagon. It would go into effect 30 days after publication.

All the military services have ordered a crackdown on drug trafficking and use.

"This will be extremely valuable to the Navy," said Rear Adm. Paul J. Mulloy, director of the Navy's human resources management division.

"There have been cases where boxes break open and you actually see the material, and you were not allowed to touch it unless you could get a federal postal inspector. Well, that's pretty hard to do in the middle of the Indian Ocean."

A Post Office spokesman said the agreement does not have to be approved by Congress.

A Pentagon spokesman said she knew of no objections filed against the proposal.