Long before Donald Trump was playing at statecraft in Mexico, he was in dabbling in a different kind of diplomacy in Mexico: pageant diplomacy.

And he was just as terrible at that.

It was a legal case that forms the backdrop to Trump’s views on Mexico, and how that country is taking advantage of the United States. He had been screwed in a business deal, and he never forgot it.

Years ago, Trump had signed a business agreement with businessman Pedro Rodriguez worth millions, in order to bring the Miss Universe pageant to Mexico City in 2007. While Rodriguez paid him a fraction of the cost up front, Rodolfo Rosas Moya’s properties were apparently put up in a trust as collateral for the rest.

But Trump claims that he didn’t get paid according to the agreement, and subsequent court action has failed to yield the millions of dollars he believes he’s owed.

Mexican newspapers report that Trump’s beef with Rosas Moya focuses on 25 empty lots in a plush part of Playa del Carmen. Trump even reportedly won an arbitration against Rosas Moya in Mexico in 2012—but didn’t make any progress on recouping the lost cash.

Trump believes that he is owed some $12 million from the agreement, according to a 2015 Bloomberg report. The Trump campaign did not respond to a request for comment.

His Mexican legal troubles seemed to anger him deeply—and in a tweetstorm last year he explicitly expanded his personal irritation with the Mexican legal system to implicate Mexicans more broadly.

One month after the original tweets, Trump swore that Mexico would never again host the Miss Universe pageant (he later sold the pageant after his business partners balked at his various campaign controversies). And he seemed to connect his own legal problems with his desire to build a giant barrier between the United States and Mexico.

“Mexico’s court system corrupt,” he wrote. “I want nothing to do with Mexico other than to build an impenetrable WALL and stop them from ripping off U.S.”

Rosas Moya fired back in a post called “You Lie, Donald Trump” on what Mexican newspaper La Opinion identified as his personal blog.

“I think Donald Trump has no moral standing to make statements against me or against my country, much less to make fun of Mexican law and Mexico in the way that he is doing,” Rosas Moya wrote. The statement is undated, but a Google search for the initial URL suggests it was published in March 2015.

Trump’s frustration with the Mexico pageant is hardly the only time he has experienced failure in the country. The businessman has left a trail of failed projects and unmet hopes in Mexico.

Ten years ago, before Trump wanted to “build a wall,” he planned to build a three-tower, 526-unit luxury condominium complex overlooking the ocean in Baja California. He claimed the Trump Ocean Resort Baja would be “the most spectacular place in all of Mexico.”

Within days of becoming available, more than 80 percent of the units had been sold. But by 2008 the project had stalled indefinitely. Hundreds of would-be condo owners were told that the towers would not be built. Their investment had disappeared into what amounted to a hole in the ground.

They discovered that more than $32 million in down payments and deposits had been spent, all of the investors had pulled out, and the Trump Organization would be removing its name from the project.

When the project failed to get off the ground, Trump said his role was never as a developer but that he had only lent his name to the construction for a half-million dollar licensing fee, which was eventually lost in legal fees, after a massive class action lawsuit from defrauded purchasers. More than a hundred hopeful homeowners who had put their faith in the Trump name sued him and the partner company, Irongate Capital Partners, eventually settling with the developer for $7.2 million. In 2013, the homeowners and Trump reached a separate and confidential agreement for an undisclosed amount.

Despite Trump’s frustration with doing business in Mexico, there has been repeated talk of Trump towers and massive developments in Mexico.

In 2007, the mayor of Cozumel presented a plan to preserve and develop a huge swath of bio-reserve and said a portion of the area would be a $300 million Trump development on a stretch of virgin beaches, which would have included a marina, golf course, private airstrip, and several luxury hotels in a protected area of the Mexican-Caribbean islands.

The following year, Donald Jr. and Ivanka Trump reportedly met with the mayor and representatives from a company called Mayaland just outside Cancun, to discuss the proposed development surrounding 7.5 miles of virgin beaches. According to investigative magazine Proceso, the Trump family interest in the pristine property ended that day, when the mayor allegedly requested a $20 million bribe to change the designation of the protected site for commercial usage. The Trump family has not spoken publicly about the proposal, which for several years was rumored by local government to be in the works.

As with so many other issues, Trump’s policy is based on personalities. His foreign policy is built first and foremost on personal experiences. The mutual admiration society between Trump and Vladimir Putin seems to have strongly influenced his position on future U.S.-Russia relations. Former British prime minister David Cameron’s criticism of Trump’s idea of a Muslim ban seemed poised to disrupt one of America’s most important relationships.

And as for Mexico, Trump just can’t seem to get over how two businessmen, and the Mexican court system, stiffed him out of millions of dollars.

And that is unforgivable.