President Barack Obama on Monday trolled Republican presidential candidate Donald Trump — known for his prolific use of Twitter to settle scores — making Trump the punch line for jokes on ABC's late-night show Jimmy Kimmel Live.

Obama read aloud a series of "mean tweets" culminating in one from Trump: "President Obama will go down as perhaps the worst president in the history of the United States!"

"At least I will go down as a president," Obama said.

The president appeared on the show during the middle of his three-day visit to Nevada and California, where he is campaigning and raising money for presidential nominee Hillary Clinton and other Democratic candidates. The segment contained a mix of humour and serious talk about Clinton's qualifications and the importance of voting.

Obama said the reluctance of some voters to fully embrace Clinton could be because she's so familiar to the American public, having "been in the trenches for 30 years."

Kimmel joked that Obama had to "take time away from helping rig the election" to appear on the show, a dig at Trump, who has repeatedly said the Nov. 8 vote is rigged against him.

Staying in D.C.

Obama picked up on the joke while describing how comedian Bill Murray beat him in a contest to putt golf balls into a glass in the Oval Office during a recent visit - a stunt the White House designed to promote Obamacare health insurance.

"He won repeatedly," Obama said. "The glass was rigged!"

Kimmel asked Obama, "Do you ever laugh" when watching Trump on television. "Most of the time," Obama said.

Obama also revealed he has been called on a special phone by his bed "three or four times" in the middle of the night during his time in office to deal with emergencies, including when the 2011 tsunami hit Japan.

But he said he does not reach for his smartphone in the wee hours – another dig at the Republican candidate.

"I don't tweet at 3 a.m. about people who insult me," Obama said.

Obama's second and final term ends on Jan. 20. Under the U.S. constitution, presidents are limited to two terms – which is just as well, Obama said.

"If I were able to run for a third term, Michelle would divorce me," he said, noting his wife does not like politics. Obama said the family will stay in Washington in no small part so as not to move while youngest daughter Sasha is midway through high school.

Not all the jokes were at Trump's expense. Comedian Will Farrell channeled deceased but beloved Chicago Cubs sportscaster Harry Caray to recommend that Obama "open a shrimp shack" after he leaves office.

And Joel McHale feigned outrage when told he had been bumped from the show for Obama.

"You got the president, huh. Wow, that's a big deal – he's got two months left in the job," McHale said, oozing sarcasm.

"That's a real good get there, Jimmy: Lame! Duck!" McHale said.