President Trump on Friday took a jab at a potential 2020 Democratic rival, highlighting Rep. Beto O’Rourke’s loss last month in a race for a Senate seat in Texas.

“I thought you were supposed to win before you run for president,” Trump said during a bill-signing ceremony in the Oval Office.

Trump’s election as president was his first bid — and first win in a race — for elected office.

Sen. Ted Cruz (R-Tex.) was among the lawmakers on hand to celebrate the First Step Act, a sweeping criminal justice bill that passed overwhelmingly this week.

Cruz won reelection over O’Rourke, 51 percent to 48 percent, despite prolific fundraising by the Democrat, who became a favorite of liberals well beyond his state’s borders during his unexpectedly strong campaign.

Cruz congratulated several people who worked on the criminal justice bill, including Jared Kushner, Trump’s son-in-law and White House adviser, who Cruz said “poured his heart” into passing the legislation.

Trump, in turn, congratulated Cruz on his reelection.

“Congratulations on your race,” Trump said. “You won easily. Now he’s [O’Rourke] running for president. I thought you were supposed to win before you run for president.”

O’Rourke, who first won a seat in Congress in 2012, has said he is considering a White House bid.

At a town hall meeting in El Paso last week, he told constituents that he had yet to achieve “a level of clarity or an epiphany” about whether to run.