US President Donald Trump has branded former Republican speaker of the House of Representatives Paul Ryan a “baby” and a “terrible speaker”.

Mr Trump’s comments came after the former congressman was quoted in a new book as saying the president did not know anything about governing and that he retired to get away from him.

Mr Trump unleashed his criticism on one of Wisconsin’s favourite sons just before leaving to go to the state he wants to win in 2020. He called the retired congressman’s record “atrocious”.

Mr Trump said: “Paul Ryan let us down. Paul Ryan was a terrible speaker. Frankly, he was a baby. He didn’t know what the hell he was doing.”

Mr Ryan condemns Mr Trump in American Carnage, by political reporter Tim Alberta.

Mr Alberta wrote that the former speaker, who retired from Congress in 2018, could not stand the idea of another two years with the Republican president and saw retirement as the “escape hatch”.

Mr Ryan is quoted saying: “I’m telling you, he didn’t know anything about government. I wanted to scold him all the time.”

Pushing back, Mr Trump told reporters that one day when he was making a speech in Wisconsin, he invited Mr Ryan, who was booed.

“So for him to be going out and opening his mouth is pretty incredible,” Mr Trump said. “Maybe he gets paid for that. Who knows?”

On Thursday evening, Mr Trump posted tweets labelling Mr Ryan as a “lame duck failure”.

“He had the Majority & blew it away with his poor leadership and bad timing,” Mr Trump tweeted. “Never knew how to go after the Dems like they go after us. Couldn’t get him out of Congress fast enough!”

Mr Ryan’s spokesman said he had no comment on the president’s tweets about him.

Mr Trump may have been angered by various revelations in the book, including accounts recalling widespread negative Republican reactions to his off-colour videotaped comments in the Access Hollywood scandal in the closing weeks of the 2016 election campaign. Mr Ryan’s reaction was particularly harsh.

The book recounted Mr Ryan, who served in Congress for 20 years, saying Mr Trump’s presidency was slipping as he was less willing to accept advice from Republicans to moderate his approach.

“Those of us around him really helped to stop him from making bad decisions. All the time,” Mr Ryan said. “We helped him make much better decisions, which were contrary to kind of what his knee-jerk reaction was. Now I think he’s making some of these knee-jerk reactions.”

And Mr Ryan, who often was Mr Trump’s wing man on some congressional issues but had a strained relationship with him, was the main focus of Mr Trump’s Twitter rage.

“Paul Ryan, the failed V.P. candidate & former Speaker of the House, whose record of achievement was atrocious (except during my first two years as President), ultimately became a long running lame duck failure, leaving his Party in the lurch both as a fundraiser & leader,” Mr Trump tweeted.

Mr Trump tweeted that when presidential candidate Mitt Romney chose Mr Ryan as a running mate “I told people that’s the end of that Presidential run”.

“He quit Congress because he didn’t know how to Win,” Mr Trump tweeted.