WILLIAMSPORT, PA. -- Rudy Giuliani, representing a client inside a courtroom for the first time in nearly three decades, showed some rust as he tried to make the case that President Donald Trump has been robbed of reelection.

The former federal prosecutor and New York City mayor, who has taken over Trump's efforts to overturn the election results, entered a courthouse Tuesday in Williamsport, Pennsylvania, with a few dozen Trump supporters cheering him from across the street.

Over the next several hours, he fiddled with his Twitter account, forgot which judge he was talking to and threw around wild, unsupported accusations about a nationwide conspiracy by Democrats to steal the election.

No such evidence has emerged since Election Day.

Giuliani needled an opposing lawyer, calling him "the man who was very angry with me, I forgot his name."

He mistook the judge for a federal judge in a separate Pennsylvania district who rejected a separate Trump campaign case: "I was accused of not reading your opinion and that I did not understand it."

And he tripped himself up over the meaning of "opacity."

"In the plaintiffs' counties, they were denied the opportunity to have an unobstructed observation and ensure opacity," Giuliani said. "I'm not quite sure I know what opacity means. It probably means you can see, right?"

"It means you can't," said U.S. District Judge Matthew Brann.

"Big words, your honour," Giuliani said.

Giuliani acknowledged in court that a portion of the lawsuit had been "mistakenly" removed and, under questioning by Brann, that the lawsuit did not actually allege election fraud, despite his claims about it.

At times, Giuliani struggled to answer Brann's questions, or the Philadelphia lawyer working alongside Giuliani, Linda Kerns, took over in answering

At one point, an opposing lawyer, Mark Aronchick, disputed Giuliani's repeated contentions that it was illegal for counties to help people vote.

"I don't expect that he would know the Pennsylvania election code," Aronchick said, suggesting -- without saying it -- that Giuliani was an unprepared out-of-towner.

And while still in court, he retweeted someone who said he did a great job in his opening remarks.

The Trump campaign is seeking to prevent Pennsylvania from certifying its election. The lawsuit is based on a complaint that Philadelphia and six Democratic-controlled counties in Pennsylvania let voters make corrections to mail-in ballots that were otherwise going to be disqualified for a technicality, like lacking a secrecy envelope or a signature.

It is not clear how many ballots that could involve, although some opposing lawyers say it is far too few to overturn the election result. President-elect Joe Biden won the state by more than 80,000 votes.

On Tuesday, opposing lawyers asked Brann to throw out the case, calling the evidence cited "at best, garden-variety irregularities" that would not warrant undoing Pennsylvania's election results, which delivered the White House for Biden.

Once a hard-nosed federal prosecutor who made a name for himself going after New York mobsters in the 1980s, Giuliani had not appeared in court as an attorney since 1992, according to court records.

Giuliani was the U.S. attorney in charge of the high-profile Southern District of New York before he won his second race for New York City mayor in 1993.

He was still the mayor during the Sept. 11, 2001, terrorist attacks but was term-limited and left office in early 2002. He ran for president in 2008.

Long in Trump's orbit, Giuliani became a fierce attack dog on Trump's 2016 campaign, lending his celebrity to the underdog effort and earning Trump's gratitude. He emerged as a major player when the president made him the public face of his legal team during special counsel Robert Mueller's Russia investigation.

Giuliani later drew blame from others close to Trump for putting unproven conspiracy theories in front of the president about work that Biden's son, Hunter, did in Ukraine. Trump was impeached in the aftermath of pushing Kyiv to investigate the Bidens.

Giuliani burst back into the public eye in the stretch run of this election but has little to show for the Trump campaign's legal efforts.

And he became a punchline when he held a news conference in front of a Philadelphia landscaping company, across from an adult bookstore, when the race was called for Biden.

In Williamsport -- a small city best known as host to the Little League World Series -- Giuliani's arrival and departure from the courthouse was made smooth by law enforcement and court personnel, who allowed his two black SUVs to remain parked directly in front of the building.

As he left the courthouse Tuesday night, Giuliani, 76, appeared unconcerned whether he'd lose that case -- "well, obviously if we lose it, we'll appeal it" -- and suggested that the Trump campaign's eggs are not in one basket.

"There are eight cases, I'm afraid to tell you," Giuliani said.

------

Levy reported from Harrisburg. Associated Press writers Jonathan Lemire and Colleen Long in Washington contributed to this report.