CLEVELAND — Donald Trump needs the performance of a lifetime.

The Republican nominee’s speech tonight will cap off a convention that has so far been a rolling disaster of infighting and poor planning -- all playing out on the national stage at a time Trump desperately needs a boost to compete against frontrunner Hillary Clinton.

The problems began the first day in Cleveland and continued right up to Senator Ted Cruz’s dramatic call to “vote your conscience” on Wednesday night, compounded along the way by numerous mistakes by the Trump campaign that created damaging distractions and extended existing ones.

Related: Latest Updates and Analysis from the RNC

The week has seen a divisive floor fight, a feud with the host state’s Republican governor, a sea of empty seats for primetime speeches, a three-day plagiarism scandal involving the candidate’s wife, and finally the explosive display around Cruz that wiped vice presidential nominee Mike Pence’s speech out of the headlines and set Republican party activists here aflame heading into the convention’s final day.

Trump, who has never been one to let slights go unanswered, now faces the daunting challenge of delivering a speech that refocuses his campaign and rallies the party. Based on his predictable response to Cruz so far – a series of mocking tweets – it will take all his restraint not to turn his address into a long point-by-point response to every criticism he’s received this week, just as he has in so many speeches before.

Sen. Ted Cruz flashes a thumbs up as he leaves the stage. J. Scott Applewhite / AP

Cruz’s non-endorsement seemed to release all the emotions and grievances that the party had tried to suppress after the primary at once on Thursday, prompting a spasm of infighting at the worst possible time.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

As the senator made clear, this was no accident.

“I am not in the habit of supporting people who attack my wife and attack my father,” Cruz said at a breakfast with Texas delegates the next morning, saying he would not be a “servile puppy dog” to Trump.

After Cruz’s morning event, angry members of the Texas delegation engaged in shouting matches over whether to support Cruz or Trump, with one man calling another a “coward” in front of a group of reporters.

On MSNBC’s Morning Joe, Donald Trump Jr. relayed that Texan donors told him they were “never writing a check to [Cruz] again.” Rep. Peter King of New York, a longtime Cruz critic, told NBC News the senator was a “fraud” and a CNN reporter that the word “a--hole” didn’t do the senator justice, an assessment that RNC spokesman Sean Spicer concurred with in a later interview.

New Jersey Governor Chris Christie railed against Cruz’s “selfish” and “awful performance” to NBC News. Cruz’s former campaign manager Jeff Roe shot back that Christie “turned in his political testicles long ago” in an interview with a Philadelphia radio station.

Adding to the fire, Trump gave a bizarrely-timed interview to the New York Times Wednesday on foreign policy – an especially divisive topic within the GOP that’s firmly outside his comfort zone – in which he suggested he may abandon NATO allies if Russia were to invade and said the US had lost its moral authority to criticize authoritarian regimes.

“When the world looks at how bad the United States is, and then we go and talk about civil liberties, I don’t think we’re a very good messenger,” Trump said.

The remarks were completely out of character in a party whose leaders have spent the last seven years seething at President Obama’s alleged disdain for “American exceptionalism” and unwillingness to confront threats to allies. “We cannot have four more years apologizing to our enemies and abandoning our friends,” Pence said in his own vice presidential acceptance speech on Wednesday.

Trump’s threat prompted brushbacks from Estonia’s president, NATO’s Secretary General, and finally Senate Majority Leader Mitch McConnell, who spoke on behalf of Trump at the convention just two days earlier.

"NATO is the most important military alliance in world history,” McConnell told Politico. “I want to reassure our NATO allies that if any of them get attacked, we'll be there to defend them."

The chaotic reaction to Cruz and Trump’s casual drift into an international incident were emblematic of the week’s proceedings.

Trump, who has made his negotiating skills the centerpiece of his campaign, somehow managed to work out a deal that allowed a rival whose family he had viciously attacked to take the stage in primetime without insisting on his endorsement first. Nor was Cruz’s big moment a surprise: The line that set the crowd off was in prepared remarks sent out to reporters well before he took the stage.

The reaction from the campaign the next day, as it had been to so many crises before, was all over the map. Trump, family members, and aides insisted they had let Cruz to speak with clear eyes even as they denounced his remarks as a betrayal and cheered on his detractors.

“Don't come out on stage if you don't want to endorse,” Eric Trump, who also suggested Cruz’s speech was “political suicide,” told NBC News. “Don't come out on stage if you don't want to be supportive.”

The confusing message – Cruz’s speech was party treason, but we approved it anyway – mirrored the campaign’s incompetence managing the fallout over Melania Trump’s use of passages from Michelle Obama had used in her 2008 convention address.

Rather than quickly admit a mistake on Monday night, apologize, and move on, the campaign bounced between ridiculous denials that any plagiarism occurred and partisan conspiracy theories that Hillary Clinton was behind the story before finally releasing a statement from a speechwriter admitting the speech lifted language from Mrs. Obama. The bumbling response extended a damaging one-night story into a three-day affair in which the campaign eventually had to acknowledge that their initial defense of the speech – which included talking points referencing “My Little Pony” – was flat-out false.

Now Trump is set to end the convention as he began it: The center of attention, beset by enemies on all sides, with the fate of the party on his shoulders. The convention’s made clear that despite whatever now-tired talk of a “pivot” to the general election, Trump will go into the general election unabashedly himself. We can only wait to see what form it takes on Thursday night.