TOKYO (AP) _ A major Cabinet member at the center of a sex scandal resigned Friday, shaking a 2-week-old administration that has pledged to clean up Japan's seamy politics.

The resignation of Chief Cabinet Secretary Tokuo Yamashita, the main government spokesman and top lieutenant to Prime Minister Toshiki Kaifu, came one month after former Prime Minister Sousuke Uno, plagued by allegations of extramarital affairs, announced he was stepping down.

Mayumi Moriyama, head of the Environment Agency, was chosen to replace Yamashita, an official at the prime minister's office said, speaking anonymously. Mrs. Moriyama, 61, will be the first woman to hold that post.

Mrs. Moriyama is serving her second term in the upper house of Parliament, and was first elected in 1980. The environment portfolio was her first Cabinet post.

On Thursday, Yamashita acknowledged his liaison with a bar hostess. The acknowledgement came the same day the weekly magazine Shukan Shincho published a story describing the relationship that began in 1984, when the woman was 21, and lasted more than three years.

''The Kaifu administration had placed cleaning up politics at the head of its agenda and had been entrusted with the hopes of the people ... but in the end I have decided that I must resign,'' he said at a televised press conference late Friday morning.

''I must offer my deepest apologies,'' he said. He added that he had apologized to his wife and that she had forgiven him. Yamashita, 69, and his wife, Kyoko, have been married 45 years and have four grown daughters.

Earlier Friday, he met with Kaifu at the prime minister's official residence, and later attended a regular weekly gathering of Cabinet ministers.

''The task of the Kaifu Cabinet is to promote clean government, and as I must follow that and support the prime minister ... I can offer only my deepest apologies to the people of Japan,'' Yamashita told a televised news conference Thursday.

Yamashita was appointed two weeks ago, when Kaifu formed a government after Uno quit because of an election defeat that cost the Liberal Democrats their majority in the upper house of Parliament.

Uno was in office only two months, hounded by allegations that he had kept paid mistresses.

Noboru Takeshita, the man Uno succeeded, resigned to accept responsibility for the Recruit Co. influence-buying scandal, which reached the top ranks of government, bureaucracy and business. Uno was chosen because it had not touched him.

The latest scandal was considered likely to erode public support for the Kaifu administration, which has said its priority is restoration of political ethics.

Japanese society has been tolerant of rich and powerful men having affairs and mistresses, and only recently have such matters been reported. Yamashita said Thursday: ''That such news would be reported was due completely to my own indiscretion.''

Yamashita had a reputation as a ''clean'' politician. He was chosen because he belongs to the same party faction as Kaifu and was not identified with the influence-buying scandal, which contributed to the election defeat last month.

Yotaro Konaka, a prominent author and social critic, said Thursday: ''The public is not going to tolerate such insensitivity by political leaders. People must doubt if the new government, which appointed such a person to its top post just when political ethics has become a national issue, has any common sense at all.''

Political analyst Masaya Ito said the scandal ''is particularly damaging for Kaifu. ... The public is not going to believe what he says from now on after such a digusting scandal. I am sure many people are already feeling sick and tired of finding out about new scandals of their country's leaders.''

Shukan Shincho said in its edition published Thursday that Yamashita conducted the affair while serving as transport minister and head of the Management and Coordination Agency.

It said he gave the woman 3 million yen ($21,000) on Aug. 3, when there was speculation he would get a high post in the new government, and the woman returned it three days later, the magazine said.

Yamashita was quoted as denying he tried to buy silence and saying: ''I did it from my own good intentions after hearing that she's still having problems in her life.'' The woman was not identified.