The Treaty of Rio de Janeiro
The treaty ending the Spanish-Confederate War was negotiated interestingly in Rio de Janeiro, largely because it was contentious where to even hold the meeting. It was ultimately held in Rio de Janeiro, because the Confederates felt that Brazil, a New World nation with slavery, would be sympathetic to them, while the Spaniards believed shared Catholicism and Iberian heritage would bind them together. In reality, the Brazilians at the meeting were rather even-handed.
Many reasons pushed the parties together. The Mexicans had everything they wanted, so they were already up for peace. The Spanish, while being the far less devastated primary belligerent, also were horrified at the losses their army had taken. The Spanish garrison in Cuba was destroyed, reinforced by a giant army in Spain, which was then also largely destroyed. In addition, Spanish armies in Charleston and New Orleans had also been destroyed. The Confederates and Americans held more than a mind-boggling 100,000 Spanish troops in various prisoner of war camps across the Confederacy, where many were dying of infectious diseases and malnutrition (which in turn lowers disease immunity, leading to more deaths). Not due to Confederate war crimes, but just because the Confederate economy had totally collapsed. In fact, as conditions in the camps grew worse and public order began collapsing, many Confederate officers simply released the Spanish POWs, sending them to local towns where they were asked to help keep public order. The Spaniards were actually shocked at this act of charity, especially as many of these Spanish troops had just looted Southern cities and understood they could just easily move south into Georgia to support the Spanish Army. Surprisingly, most of them stayed, helping restore public order in Southern towns (who often had a shortage of healthy-bodied young and middle-aged men).
It went without saying that the Confederates obviously wanted peace as soon as possible just so they could rebuild their nation. The Provo rebellion was in collapse, but large parts of the country were still in chaos. Finally, the United States wanted peace as soon as possible, largely because President Clay did not believe he would win re-election. Secretary of State Blaine's proposal to massively expand and modernize the US Navy was stopped by Clay as a useless expenditure when he entered office. Now, almost every sunken US ironclad and drowned American sailor was being blamed on him by Blaine. Who was going to be the Republican nominee for President. The Blaine campaign focused on anti-Catholicism/nativism, support for aggressive foreign policy (including annexing Cuba), and castigating Clay for the recession (largely caused by the war Clay was trying to stop). Clay hadn't even decided to run again, as the situation seemed so hopeless. He deeply did not want to see the United States annex Cuba, so he was in a hurry to conclude the peace agreement before the election.
Hammered out after several sessions, the Treaty of Rio de Janeiro finally ended the Spanish-Confederate War as follows:
1. Cuba was to become an independent "Confederate Viceroyalty of Cuba", which was totally self-governing, but technically still recognized the King of Spain as their ceremonial monarch. The Cuban revolutionary army was to be renamed the "Royal Cuban Army" as a sop to the Spanish, but left with all of the same revolutionary leaders. This allowed Cuba to be independent in every meaningful way, but let the Spanish pretend otherwise at home. The Cuban Revolutionaries were only mollified by being allowed to refer to Cuba as the "Republican Monarchy" in most official correspondence.
2. In compensation for Cuba, the Spanish would be granted Confederate North Borneo, which had surrendered peacefully in the first week of the war.
3. A final settlement on the Texas-Mexico dispute was drafted. The border was allowed to be moved up to the Nueces River, with the rest of the border decided by literally drawing a line from the Western terminus of the Nueces River to the Southeastern tip of the American Arizona territory. As compensation, the Mexicans would pay a significant share of $$$ into the "Freedman's Fund", which was to help finance any Confederate loans taken to compensate slaveholders for any blacks born free.
4. Spain was allowed to maintain its presence in Savannah as a "free trade port", where the Spanish could freely dock ships and garrison troops. In addition, Spanish traders were subject to Spanish law instead of Confederate laws. This port was granted to Spain as a 50-year lease, thus expiring in 1938. However, Spain was forced to pay for the lease, with the proceeds going into the Freedman's Fund. Interestingly, Spanish finances were heavily wrecked by the war, so to pay into the Freedman's Fund...they were forced to borrow from American banks. The Confederates agreed to this because it was catastrophic when the Spanish blockaded Confederate ports - giving the Spanish a port basically ensured that the Confederacy would always have a lifeline in a future conflict. Unless they supposed that war was with Spain again.
5. Any individual Spanish troops, militiamen, or loyalists in Cuba, were free to choose between Cuban or Confederate citizenship, which had to be accepted by all parties. Surprisingly, many Spanish troops, having heard good things about the Confederate release of POWs, actually chose the Confederacy.
6. The treaty included all of the anti-slavery provisions of the pact with the USA that would normally violate the Confederate Constitution without the treaty power. First, the treaty made it illegal for the Confederate government to intervene or prevent a state from abolishing slavery. Second, it implemented the "compensated law of the womb" in most of the states, namely Alabama, Mississippi, Texas, Tennessee, Alabama, Virginia, and Oklahoma.
Florida, Georgia, South Carolina, and North Carolina were given a compensated emancipation. However, this was essentially uncompensated in Georgia, North Florida (where almost all of the slaves were), and the Provo regions of South Carolina. Not out of extreme anti-slavery sentiment, but because almost all the slaves had simply walked off the plantations and most of the records in those regions had been destroyed in what became euphemistically called "the Troubles". In North Carolina as well as the loyalist regions of South Carolina and Florida, a compensated emancipation was drafted, to be paid for out of the Freedman's Fund. As a general rule, planters who had sided with the Nationals in these states were given compensation and those who had sided with the Provos were not. In many cases, this created furious rage, because pro-National planters actually skewed wealthy. Thus, many of those Provo planters were smaller planters who were economically ruined by the emancipation saw many wealthy planters generously compensated. The supporters of the furious Ben Tillman of South Carolina in particular were outraged, catapulting him into a position of being one of the most outspoken dissidents against the new Confederate regime.
The peace was relatively unpopular everywhere, but most Spaniards and Confederates still breathed a sigh of relief, as the horrible war was now over. Many Confederates grused about horrifying and humiliating concessions (including territory and treaty ports) and many Spaniards were angry that Cuba was "lost", but the average person in both countries was just sick and tired of the war, glad that it ended.
The Hohenzollern Monarchy in Spain responded by reinforcing what was left of its American empire, namely the island of Puerto Rico, and viewing Borneo as a possible region of colonial expansion. The political class celebrated the war as essentially a victory showing that Spain was still a great empire. The Confederates were shell-shocked, especially as General Mahone declared that he would completing John Morgan's term in office. Although some plotted to revolt against him, those ideas were squashed by General Longstreet, who returned from Cuba as a war hero and recognized the government as legitimate. Even though his refusal to surrender likely caused the horrifying crisis of the Confederacy, at the end of the day, he won in Cuba, refused to surrender when told, and then finally defeated the Spanish. Despite all of the misery suffered by the Confederacy, many took solace in the fact that their army in Cuba was ever-victorious. Mahone's first act as President was quite simple: he didn't want a coup against himself, so he decided to move the Confederate capital out of Montgomery, which he saw as a den of slave power. Instead, he carved a piece out of Georgia (which had no room to complain due to being under military administration), the city of Chickamauga on the border with Tennessee, where the Braxton Bragg's had famously crushed the Union (just south of Chattanooga, where he crushed them again), naming the new city Fort Bragg.
To shore up his support, President Mahone chose war hero Patrick Cleburne as his Vice President, who immediately drew a lawsuit claiming that the Irish-born General was not a natural-born citizen. The Confederate Supreme Court unsurprisingly immediately dismissed the claim, holding that presidential qualifications were not under the jurisdiction of the Supreme Court, but rather the sole jurisdiction of some mix of the electoral college and of the Congress (when certifying the results of the electoral college). The 1888 midterm elections were held during the war when Mahone's soldiers controlled more or less most loyalist states, so it unsurprisingly produced a clean slate of Mahone partisans. Amusingly, the Mahone Congress ruled that natural-born citizen clause referred to humans born from two biological human parents. When their opponents asked them why on earth the clause served any purpose and who it would exclude, a Mahone partisan responded jokingly: "Paddy's Catholic, so Jesus to him!" This then became the official legal doctrine in the Confederate States, as it was actually argued and accepted that the natural-born citizen clause was intended to prevent the Confederacy, especially the representatives from theocratic North Carolina, from electing Jesus Christ as President, because Christ was King, and thus electing Christ as President would be a dishonorable demotion.