In May 2008, Donald Trump, the self-professed "miracle worker," lost his magic.

And his cool.

Gov. Jon S. Corzine had just lost his patience with Trump's pledge to rescue a struggling, grandiose plan to convert abandoned garbage dumps into luxury housing and a golf course. Trump promised a majestic makeover — the toxic, woebegone wetlands along the New Jersey Turnpike would give way to glittering high rises and emerald green fairways.

But after seven months of wrangling, Corzine called it quits. He dispatched two envoys to Trump's gilded office tower in Manhattan to bluntly tell him that the deal was dead.

Trump, who was joined by his adult children and company officials, was blindsided. He was expecting a negotiation, not a termination. In fact, the meeting started off with a touch of Trumpian razzle-dazzle, as he took a phone call from the legendary former New York Yankees manager Joe Torre while the two men from New Jersey cooled their heels.

Trump put Torre on speaker phone and began to heap lavish praise on his two visitors, Gary Rose, Corzine's economic development czar, and Robert J. Gilson, director of the state Division of Law.

But it did little to deter them from the mission at hand. Moments after Rose delicately broke the news, Trump unleashed a torrent of expletives in front of his stunned guests, according to sources with knowledge of the meeting. Details of the encounter were also later outlined in a memo that Gilson wrote and circulated among administration officials.

As Trump reached a boil, he slammed a pencil on his desk, and it bounced up and plunked his daughter, Ivanka, in the forehead. One of the sources said Ivanka ran from the room, visibly upset.

Trump, who summarily dismissed contestants on his wildly popular reality television show "The Apprentice" with the fateful phrase "You're fired," was now getting a taste of his own dog-eat-dog ethos. New Jersey fired Trump.

Rose, a former Goldman Sachs executive who is now retired, declined to discuss the matter. Gilson, now a state appellate court judge, also declined to comment, through a spokesman for the state Judiciary. Officials from the Trump Organization and the White House did not respond to messages seeking comment.

The explosive encounter capped the state's turbulent, seven-month relationship with Trump, who was enlisted by a previous developer and a syndicate of banks desperate to salvage the EnCap Golf Holdings project.

But the frenzied stretch to resurrect a long-sought plan — and most likely with Trump's name on it — gave state officials a writ-small preview of the behavior that has come to shape the Trump presidency.

Trump showcased his P.T. Barnum bombast, his skill at selling bold promises, turbocharged with superlatives and gleaming, unattainable promises.

His vow, for example, to make the Meadowlands project the "finest of its kind anywhere in the world'' prefigured his 2016 campaign vow to build a "beautiful wall" along the U.S. border with Mexico.

Trump's self-casting as the miracle worker who was the only developer with the moxie and skill to salvage the EnCap project echoed his "I alone can fix it" boast from his acceptance speech at the Republican National Convention in 2016.

And his boasting that "I've never had a failure" — uttered shortly after taking over the Jersey swamplands project — offered an early indication of Trump's loose relationship with facts. By the time he took over EnCap, Trump's once-glittering Atlantic City casino empire had already withered under a steady stream of bankruptcies.

The EnCap episode offered other hints of the Trumpian future.

Trump gave a test run of his "fake news" rhetoric. He made clear his impatience with bureaucratic norms, a trait that would later shape his chaotic, outsider style of managing his administration.

One state official also recalled how Trump publicly demeaned his former fixer, Michael Cohen, during one of their first meetings with New Jersey officials. Cohen, who was Trump's devoted defender during the failed EnCap effort, has since turned on his old boss, describing him as a "con man" and a "cheat" during a congressional hearing earlier this year. Cohen began serving a three-year federal prison sentence earlier this month on tax evasion and campaign-finance-related charges.

And then there is Trump's vanity and his bottomless need for validation and to always cast himself as a winner. As president, Trump rarely missed a chance of reminding audiences of his surprise victory over Hillary Clinton.

During his Meadowlands stint, Trump repeatedly boasted of the success of "The Apprentice," which resuscitated his career. Before meetings with the New Jersey Meadowlands Commission, the state planning agency with jurisdiction over the project, Trump faxed over the latest ratings of the show.

"He spent the first 10 minutes of the meeting talking about how great the TV show and how great he was doing,'' said Joseph V. Doria, a former chairman of the commission.

But by the fall of 2007, EnCap officials and investors were desperate for a winner, or at least someone, who could pull the troubled project off life-support.

The project had been kicking around for a nearly a decade with little progress, struggling to scrape together financing, meet deadlines and keep pace with the rising costs of cleaning up four landfills in Rutherford, Lyndhurst and North Arlington.

Skepticism among state and local officials in the Meadowlands communities soared as the developer kept staggering and stalling. By June 2007, the Meadowlands Commission declared the project in default. By the following November, Cherokee Partners of North Carolina, the parent company of the EnCap project, and a syndicate of banks faced what was widely seen as one last chance to meet the state's terms by late November.

That's when they turned to Trump, the reality television star and real estate developer whose own dreams of mining gold from the nearby North Jersey meadows had been thwarted for nearly two decades.

On the day before Thanksgiving, Trump flew down to Trenton in his new capacity as savior of EnCap. He swept into the packed Department of Environmental Protection conference room with an entourage in tow — lawyers, his adult children and Cohen.

Trump's pitch was fairly simple: The project would be a success because it was now a Donald Trump project.

"It was 'everything is going to be fabulous' and all of that,'' recalled Valerie Haynes, a deputy attorney general who represented the Meadowlands Commission.

To prove his point, Trump bragged about his swift repair of the shuttered Wollman ice skating rink in Central Park in the 1980s, which branded Trump as a dashing, bypass-the-bureaucracy developer. Haynes, who chronicled every step in the project's troubled history, had her doubts.

"We're talking about 700 and some acres of compromised, contaminated land, and you're telling us you're going to be a success because you have built an ice rink?'' she said in a recent interview.

Haynes recalled that one official during the meeting suggested that one of Trump's claims about the project didn't square with some of the characterizations that Cohen had made earlier in the meeting. Trump swatted away the question with contempt.

"He said, 'Oh, that's just Michael. He doesn't know what he's talking about,' '' Haynes said. Despite Trump's cutting remarks, Cohen was listed as the Trump Organization's main point of contact for the project, she said.

Despite doubts, the state was eager for Trump to succeed, at least initially. Over the years, it had granted the developer cut-rate loans worth $350 million. Despite the problems, political leaders refused let go of the goal of turning the "swamps of Jersey,'' as Bruce Springsteen described them, into prime New York-market real estate.

But the Trump effort may have been doomed from the start.

Hostility toward EnCap had reached a boil among the South Bergen town officials and residents for years.

The discontent was fueled by long delays, promised but unfinished recreational fields in Lyndhurst, and growing fears that a creative bond financing scheme would leave local homeowners on the hook if the project collapsed. The Record's investigative series that exposed the corrupt political underpinnings of the project also inflamed suspicions.

And just after Trump signed on that November, a slew of anti-EnCap candidates won election in local races, including John W. Hipp of Rutherford, an environmental lawyer. Trump called Hipp the day after his victory to congratulate him and predict a great turnaround for EnCap.

"He [Trump] wanted to assure me that the project was going to be huge,'' said Hipp, who was particularly opposed to the planned 800 housing units for the borough. He feared the strain it would have on local infrastructure and property taxes and worried that the chosen method of sealing the landfills was insufficient.

"Basically, what I said in substance ... I'm happy to talk to you about golf courses, but I basically told him, in words and substance, no housing. He just repeated 'how much you're going to love it, you're going to love it,' " Hipp added.

Despite reservations, in January 2008, the state gave Trump 120 days to demonstrate that he was capable of cleaning up polluted landfills. Yet top Corzine officials warned that he needed to continue to hit cleanup deadlines if he wished to remain as the state's long-term partner on the project.

Trump, meanwhile, kept close tabs on the project, personally calling local officials who criticized the project in the newspapers, and showing up late for status meetings in Trenton after leaving a taping of "The Apprentice."

"He tells everybody, sorry he’s late, sorry that he has that orange look on his face, but he had TV makeup on, that he didn’t have a chance to take it off," said Robert Ceberio, the former executive director of the Meadowlands Commission. "He asked if anybody had a camera and if they wanted to have a picture with him."

It wasn't long before Trump wore out his welcome.

In March 2008, Trump called for a dramatic revision of the project into a mini-luxury golf resort, with 2 million square feet of office space and a near doubling of the number of high-rise units to 5,000.

Trump also framed the proposal with an "Art of the Deal"-style ultimatum: If state officials rejected his grandiose new plans, he would then demand $350 million in future tax revenues in Rutherford and Lyndhurst, an amount outlined in the bond financing agreement reached years earlier. But state officials later disputed his interpretation of the financing arrangement.

Corzine administration officials insisted that the landfills needed to be fully capped and cleaned before they would entertain any talk about revising the plans.

Trump had little patience for deadlines, budgets or any bureaucratic demands imposed by Trenton, several former officials said.

"We kept on telling him that he couldn't get it done, and he kept on getting angrier and angrier in the meetings I had," Doria said. "And he tried to go through the governor and say 'the governor would see I was right' and the people would come in acclamation that this was a good idea. And I kept saying 'no, this went through the public process.' ''

State officials did acknowledge that Trump made some modest progress toward landfill remediation, but they lost faith in his ability to raise and budget enough money to complete the job.

"[Trump] wanted us to pay for it. That was unacceptable,'' Corzine said in a recent interview. "He didn’t want to put any money into it."

By early May, tensions came to a head during a meeting in Trenton with Trump, Cohen and Rose, Corzine's economic adviser. Rose refused to promise support for Trump’s plans for a massive expansion of the Meadowlands housing project. For his part, Trump rebuffed Rose’s demands that the developer put up more than $120 million for the project and make good on EnCap’s $200 million in debts.

The following week, Corzine met with officials in the kitchen of the governor's mansion in Princeton and decided it was time to part ways with Trump, according to Ceberio. The Meadowlands Commission quickly voted to sever its nine-year relationship with the project. The next day, EnCap filed for bankruptcy.

And Corzine dispatched Rose and Gilson to Trump Tower to break the news. Trump's anger didn't subside after the two men left his office.

"Quite honestly, you should be ashamed of yourself for your actions and the way in which you have behaved!'' Trump wrote in a May 12, 2008, letter to Rose. "The reasons the governor did not tell me personally is that he knew what he was doing was unfair and wrong."

He lashed out at others. Corzine, the governor Trump once counted on to cut the red tape, was now the head of a "dysfunctional" administration. He asserted that Corzine now coveted the site because "my team and I have brought it back to health."

And he accused former assistant Attorney General Robert Romano of spinning falsehoods in the press. "Victory should be based on the truth, not a fabricated story that everybody knows is false,'' Trump wrote.

In a follow-up letter several weeks later, Trump struck a more conciliatory tone, offering to help the state finish "almost completed" construction of recreational fields at the project. But in a postscript, it was clear that he was still smarting over Corzine's rebuff.

"I will watch as the Field of Dreams become a Field of Nightmares!" he wrote.

In July, Trump had still not entirely let go, telling The Record that he was interested in buying the project out of bankruptcy.

"I never give up,'' he said.

But eventually he did give up and move on to other projects. He would reap millions by licensing his name on hotels and building golf courses. He led the crusade questioning Barack Obama's birthplace. And he would go on to become president of the United States.