Bill Clinton and author James Patterson have teamed up to write a novel about a president who disappears as he tries to prevent an apocalyptic cyberattack.

And the former US president believes the work of fiction could happen in reality.

Urged to collaborate by Washington lawyer Robert Barnett, who handles book deals for both of them, Mr Clinton and Mr Patterson drew on their respective backgrounds in completing a 500-page novel that topped Amazon’s best-seller list before publication.

Books Clinton PattersonThe President is Missing, written by former President Bill Clinton and James Patterson (Bebeto Matthews/AP)

Mr Patterson is among the world’s most popular and prolific fiction writers, and the novel is a characteristically fast-paced narrative, with brief chapters and dramatic plot turns.

Mr Clinton, a newcomer to novel writing whose previous books include the million-selling autobiography My Life, did not need a lot of research to tell readers what it is like to sit inside the White House Situation Room or to be briefed on a possible terrorist attack, or to imagine slipping away entirely.

“Jim wanted it to be authentic,” Mr Clinton said. “Which means: A, the physical setting has to be authentic. B, the procedures had to be authentic, and the interplay between the president and the staff and all the world leaders and everything had to have the feel of reality, and even how the Secret Service works.”

Readers may be surprised to see one experience Mr Clinton knows of well turn up in the novel — impeachment, as faced by President Jonathan Lincoln Duncan, whose foes allege he endangered national security.

The story line will surely revive an historic low point of his White House years, when he was impeached in 1998 by the House of Representatives, but acquitted by the Senate, on charges stemming in part from his affair with White House intern Monica Lewinsky.

But Mr Clinton expressed little concern about mentioning impeachment. In the novel, Duncan notes that a president can be impeached for anything, “It doesn’t have to be a crime”.

Mr Clinton said he wanted to present accusations which, if true, would merit removal from office.

“We (also) wanted to show something that if you were going to testify to Congress, or if you were going to do a full blown news conference, that you have to — I don’t care how good you are — you have to sort of do a prep run, you have to test it, you have to have people who work for you just pounding the living daylights out of you,” Mr Clinton said.

“We went back and forth on that chapter,” Mr Patterson said.