The suspect accused of trying to assassinate Donald Trump at his Florida golf course wrote a chilling note months earlier declaring he intended to kill the former president, the Justice Department said Monday.

Ryan Wesley Routh, 58, allegedly dropped the note — addressed “To the World” — off in a box at an unnamed person’s home in the months before the foiled assassination attempt at the West Palm Beach golf course on Sept. 15, federal prosecutors said in a court filing.

The note Routh allegedly wrote wrote note indicating he intended to kill Trump.

“This was an assassination attempt on Donald Trump but I failed you,” the letter read.

“I tried my best and gave it all the gumption I could muster. It is up to you now to finish the job; and I will offer $150,000 to whomever can complete the job.”

The handwritten note was only discovered after the person opened the box and alerted authorities in the wake of Routh’s arrest, prosecutors said.

The box also contained “ammunition, a metal pipe, miscellaneous building materials, tools, four phones” and multiple other letters.

It wasn’t immediately clear if Routh allegedly wrote the note on the premise that the assassination attempt would be unsuccessful, or if he was referring to another apparent plot.

Elsewhere in the letter, the suspect ripped Trump’s handling of Iran, writing: “He [the former President] ended relations with Iran like a child and now the Middle East has unraveled.”

Details of the letter were included in a detention memo filed Monday — as the Justice Department argued Routh should remain locked up pending his trial.

Routh was taken into custody after a Secret Service agent spotted the muzzle of an AK-style rifle sticking through the shrubbery lining the golf course and opened fire before the suspect could take a shot at Trump.

The alleged would-be assassin dropped his rifle and then fled in an SUV — leaving behind his firearm, two backpacks and a GoPro camera, according to court filings.

He was stopped and arrested some 40 minutes later.

Authorities who searched his car subsequently found six cellphones, including one that showed a Google search of how to travel from Palm Beach County to Mexico, the court papers charge.

They also found a list with dates in August, September and October – as well as venues where Trump had appeared or was scheduled to appear, according to prosecutors.

A notebook found in his car was allegedly filled with criticism of the Russian and Chinese governments and notes about how to join the war on behalf of Ukraine.

An attorney for Routh didn’t immediately respond to an email seeking comment Monday morning.