Nancy Pelosi is speaker again for one reason: her party picked up 40 seats in mostly moderate districts.

And yet the Democrats are being yanked to the left by their most visible uber-liberals, creating a huge image problem for the 79-year-old congresswoman.

With the left-wingers grabbing the lion's share of media attention, President Trump is already trying to run against her party as a bunch of wild-eyed socialists.

That leaves Pelosi with the unenviable task of preventing the Democrats from being defined by their most ideological members — and yes, the irony that this challenge falls to a classic San Francisco liberal is unmistakable.

Democrats aren't the world's most organized party. Holding together a fractious caucus has never been an easy task. And there are lingering levels of distrust from the way the establishment favored Hillary Clinton in 2016 over Bernie Sanders, who now finds himself the nominal front-runner for 2020.

FOX NEWS' BERNIE SANDERS TOWN HALL VIEWING NUMBERS BEAT CNN, MSNBC COMBINED

With the party obsessed with knocking off Trump, keeping a façade of unity may well be impossible.

"The far left's frustration with House Speaker Nancy Pelosi is on the rise," The Washington Post declares.

The latest contretemps revolves around Ilhan Omar, one of the first two Muslim congresswomen, who has repeatedly stirred controversy with comments viewed as anti-Semitic. It was Pelosi who had to steer passage of a House resolution condemning anti-Semitism and other forms of bigotry that was watered down by not mentioning Omar.

Now the Minnesota lawmaker is in a war of words with Trump, triggered by her remarks about 9/11. Omar complained that Muslims were being treated as second-class citizens because "some people did something and that all of us were starting to lose access to our civil liberties." The New York Post put a photo of the burning twin towers on the front page with the headline, "Here's Your Something."

The president pounced by retweeting a post that called Omar a "sick monster." He posted a video with footage of the World Trade Center — titled "WE WILL NEVER FORGET!" — with Omar's remarks spliced in.

PELOSI APPEARS TO TAKE NEW JAB AT AOC, SAYS 'A GLASS OF WATER' WITH A 'D' COULD WIN SOME DISTRICTS

When Omar started receiving death threats, some in the media blamed Trump, as if criticism of a politician is the equivalent of inciting crackpots against her. But the situation was certainly inflamed.

The Post reports that "Omar's allies over the weekend were upset by what they viewed as Pelosi's delayed response" in supporting her colleague. Her first statement criticizing Trump made no mention of Omar. Pelosi ratcheted up her rhetoric on Monday, saying the president's sharing of the video was "beneath the dignity of the Oval Office."

Liberals are also upset, according to the paper, at Pelosi's jibe at Alexandria Ocasio-Cortez during a "60 Minutes" interview. Pelosi said AOC's "wing" of the party included "like five people."

DOZENS OF DEMS VOTE 95 PERCENT OF TIME WITH AOC DESPITE PELOSI CLAIM BLOCK IS 'LIKE FIVE PEOPLE'

Trump has ramped up his attacks on Omar, saying Monday that she's "very disrespectful" toward both America and Israel and has "got a way about her that's very, very bad for our country."

The president is also using Omar as a way of dinging Pelosi. Keep in mind that Trump has not directly assailed Pelosi — not even bestowing a nickname on the woman who seemed to have outmaneuvered him during the 35-day government shutdown.

Look at this presidential tweet: "Before Nancy, who has lost all control of Congress and is getting nothing done, decides to defend her leader, Rep. Omar, she should look at the anti-Semitic, anti-Israel and ungrateful U.S. HATE statements Omar has made. She is out of control, except for her control of Nancy!"

Trump is essentially saying that Pelosi has lost control to her left-wing zealots, and has been reduced to an Omar puppet. Pelosi actually runs the House with a strong hand, but Trump's slam nicely dovetails with his desire to run against the Omar/AOC/Bernie "socialists."

Liberal critics are accusing the president of using bigoted rhetoric.

CLICK HERE TO GET THE FOX NEWS APP

"If Omar is a target, it has little to do with what she said and everything to do with who she is: A black Muslim woman — and an immigrant — whose very person disrupts the exclusionary ideal of a white Christian America," says Jamelle Bouie, an African-American columnist for The New York Times.

It's all gotten pretty ugly, no question about it. Ilhan Omar, although she apologized once for anti-Semitic comments, does not appear to be a conciliatory politician. And neither, of course, is Donald Trump.

But there is a payoff to waging such high-profile fights: Omar raised $832,000 in the first quarter of the year, more than all but a few House Democrats.