WASHINGTON, Sept 28 (Reuters) - U.S. General Mark Milley, chairman of the Joint Chiefs of Staff, fended off perhaps the most personal and direct attacks from lawmakers of his career on Tuesday as Republicans blasted his calls with China and his interviews for books critical of Donald Trump's presidency.

Milley, 63, was unshaken as Republicans called for his resignation during an already contentious hearing that was meant to focus on the chaotic U.S. withdrawal from Afghanistan - but repeatedly swerved into questions regarding the general.

When asked, Milley acknowledged talking to Washington Post author Bob Woodward for a book that showcased Milley's role trying to avert a crisis over apparent Chinese fears that Trump might attack Beijing in his final months in office.

The book detailed supposedly "secret" calls with General Li Zuocheng of the People's Liberation Army on Oct. 30, 2020 and again on Jan. 8, and said Milley had promised to warn China first if he were ordered to attack.

Milley confirmed the calls but said they were not secret to U.S. government officials and that he was acting on instructions from some of Trump's top aides to de-escalate tensions. He acknowledged trying to send a message that "we are not going to attack you" following U.S. intelligence indicating Beijing feared an attack.

Republican Senator Dan Sullivan challenged Milley, insinuating he would be executed for that kind of behavior in China.

"If the head of the PLA called you and said, 'Hey, we're getting ready to invade Taiwan' and (Chinese President) Xi Jinping found out about it, he'd be shot," Sullivan said, referring to China's People's Liberation Army.

Milley said the calls were part of his mandate to ensure strategic stability.

"I know, I am certain, President Trump did not intend on attacking the Chinese and it is my directed responsibility to convey presidential orders and intent," Milley told the Senate Armed Services Committee.

Trump, who has said Milley should be fired if the acounts were true, issued a statement after the hearing ridiculing the Army general.

"No wonder the Afghanistan withdrawal was such a disaster. 'General' Milley spent all of his time talking to these Fake Book writers," Trump said.

Senator Angus King, an independent committee member who caucuses with Democrats, praised Milley. "I think he was rendering the country a significant service," King told reporters on a conference call after the hearing.

The committee's Democratic chairman, Senator Jack Reed, also told reporters that de-escalating international tensions was part of Milley's job.

Milley acknowledged that he also spoke on Jan. 8 with U.S. House of Representatives Speaker Nancy Pelosi, who, according to the Washington Post, had asked the general what safeguards were in place to prevent an "unstable president" from launching a nuclear strike.