So it turns out Donald Trump got the joke after all. Or maybe he was the one who put one over on everyone else.

Either way, the reality-TV star and real estate mogul has concluded that the time has come to end it.

“After considerable deliberation and reflection, I have decided not to pursue the office of the presidency,” Trump announced in a statement Monday. But he added: “I maintain the strong conviction that if I were to run, I would be able to win the primary and, ultimately, the general election.”

No one ever knew for sure whether Trump’s flirtation with a 2012 bid was more serious than his earlier ones had been in 1988 and 2000, or whether it was simply his latest attention-getting, ratings-boosting stunt.

Had he run for the Republican nomination, it would have been the most ambitious brand-extension effort yet for a man who has slapped his name on, among other things, luxury hotels, country clubs, men’s clothing, bottled water, chocolate and the Miss Universe pageant.

Trump originally said he would not reveal his decision until next Sunday’s season finale of his NBC show, “The Celebrity Apprentice.” But another deadline may have overridden his showman’s impulses: Monday was the day that NBC, which has been struggling in the ratings, was scheduled to present its fall schedule to advertisers in New York.

Network executives reportedly had been pressuring Trump, whose show is one of the network’s most popular, to make his intentions clear. When he appeared onstage for what is known as “upfront” presentation, advertisers cheered.

Trump’s announcement came two days after former Arkansas governor Mike Huckabee bowed out of next year’s race, during his own television show on Fox News Channel. Trump made a cameo on Huckabee’s show, which, in retrospect, may have been a clue.

Huckabee’s decision to forgo the race is likely to have a far greater impact on the field, considering that he was a serious contender four years ago and won the first-in-the-nation caucuses in Iowa.

The list of candidates is still taking shape in a GOP nominating race that appears as wide open as any in generations. Among those officially running are two former governors, Mitt Romney of Massachusetts and Tim Pawlenty of Minnesota, and former House speaker Newt Gingrich (Ga.).

A number of establishment Republicans are pleading with Indiana Gov. Mitch Daniels to enter the contest, while tea party activists are still holding out hope that former Alaska governor Sarah Palin will jump in.

However unlikely the idea of a Trump presidency was, the force of his celebrity took him to the top of some polls. And he became a fixture on cable news channels and morning shows as he persistently stoked doubts that President Obama was born in the United States.

“Donald Trump was an anti-establishment figure who demonstrated the importance of taking the debate right to Obama — frontally and hard, which the eventual GOP nominee must do daily to win,” said Scott Reed, a Republican strategist.

The high point of his protocampaign — or the low one, depending on how one looks at these things — came in late April. Obama released a long-form version of his birth certificate just moments before Trump’s helicopter touched down in New Hampshire for his first visit as a possible candidate.

“I am really honored, frankly, to have played such a big role in hopefully — hopefully — getting rid of this issue,” Trump told the media swarm that had awaited his arrival. Cable channels carried the scene as a surreal split-screen with Obama’s appearance in the White House briefing room, where he referred to the birth-certificate frenzy as “this silliness.”

Trump’s triumph turned to mortification only days later, at the annual White House Correspondents’ Dinner in Washington (where Trump was a guest of The Washington Post). Trump found himself the butt of jokes by Obama and his own fellow NBCer, “Saturday Night Live” comedian Seth Meyers. He glowered as a ballroom packed with Washington and Hollywood elite roared at his expense.

“Just recently, in an episode of ‘Celebrity Apprentice’ at the steakhouse, the men’s cooking team cooking did not impress the judges from Omaha Steaks,” the president said. “. . . You fired Gary Busey. And these are the kind of decisions that would keep me up at night. Well handled, sir. Well handled.”

The difference between reality-show executive decision-making and the kind that goes on in the Oval Office was underscored just about 24 hours later, when NBC cut away from the airing of “The Celebrity Apprentice” for Obama’s announcement that U.S. forces had killed Osama bin Laden in Pakistan.

Meanwhile, Trump got a taste of the kind of scrutiny that goes with a presidential bid: The Post reported that he had favored Democrats in the more than $1.3 million in campaign contributions he made over the years; the New York Times looked into failed and fraudulent projects to which Trump had licensed his name; and the Los Angeles Times examined how the proud free marketeer had profited from government tax breaks and grants.

The Trump who returned to New Hampshire for a second appearance last week was not such an exultant figure.

“Nobody said it was going to be easy, but I had no idea I would get hammered in the way I’ve been hammered the past few weeks,” he said in an appearance arranged by the Greater Nashua Chamber of Commerce.

Trump’s 50-minute presentation before a sold-out crowd of 700 business leaders touched on China, Pakistan, gas prices, health-care reform and buying 4,000 flat-screen TVs for his hotels. He suggested that his book, “The Art of the Deal,” should be a road map for House Budget Committee Chairman Paul Ryan (R-Wis.) and for foreign policy.

One woman in the audience advised him to be open to compromise if he were elected president and added: “Can I just say one other thing? I hope the two Johns go head to head in the final.”

For a moment, Trump seemed at a loss. And then it dawned on him.

“I thought you were talking about the candidates. I was trying to figure out which ones,” he said. “That’s right. ‘The Celebrity Apprentice.’ We have two of them named John.”

Staff writers Chris Cillizza and Emily Yahr contributed to this report.