The memoirs of the man who marched beside the Rev. Martin Luther King Jr. depict him as a leader of outstanding moral character but who had a weakness for women, even on the night before his assassination.

"And The Walls Came Tumbling Down," published this month by Harper & Row, chronicles the Rev. Ralph David Abernathy's life as a preacher and civil rights activist, including his many years as King's closest friend and confidant.Abernathy reveals that King had encounters with various women on the night before his April 4, 1968, assassination at a Memphis, Tenn., hotel.

The revelation corroborates longstanding reports that King had extramarital affairs.

But in an advance copy of the book, Abernathy staunchly defends his friend's morality, without condoning his activities. He explains that he felt compelled to write of "my friend's weakness for women," and devotes part of one chapter in the 610-page book to King's private affairs.

King "believed in the biblical prohibition against sex outside of marriage. It was just that he had a particularly difficult time with that temptation," Abernathy wrote. "We all fall short of the mark . . . Sexual sins are by no means the worst. Hatred and a cold disregard for others are the besetting sins of our time."

Abernathy said he might have avoided the matter had others not dealt with it in detail.

He said he wanted "to make some attempt to render justice to the dead without causing too much unnecessary pain to the living."

Abernathy names none of the women with whom King allegedly was involved. He said extended travels during the civil rights movement were one reason, but not the main one, for King's extramarital liaisons.

"He was . . . a man who attracted women, even when he didn't intend to, and attracted them in droves," Abernathy said. "He was a hero - the greatest hero of his age - and women are always attracted to a hero."

Abernathy praised his friend for courage, saying had King "been a coward rather than a truly brave man . . . we might still be riding in the back of buses and eating in segregated restaurants."

He also said he felt other King aides saw him as "no more than an appendage to Martin, someone who served as a part companion, part bodyguard, but who never played an important role in the decisions that affected the direction of the movement."