SAO PAULO (Reuters) - Dilma Rousseff was thoroughly charmed.
Brazil had been struggling for years to decide which company to choose for a $4 billion-plus fighter jet contract, one of the world's most sought-after defense deals and one that would help define the country's strategic alliances for decades to come.
But Rousseff, the leftist president known for being sometimes gruff and even standoffish with foreign leaders, was thrilled after a 90-minute meeting in Brasilia on May 31 with U.S. Vice President Joe Biden.
After Biden's reassurances that the United States would not block crucial transfers of technological know-how to Brazil if it bought the jets, she was closer than ever to selecting Chicago-based Boeing to supply its fighter, the F/A-18 Super Hornet.
"She's ready to sign on the dotted line," one of her senior aides told Reuters at the time. "This is going to happen soon."
And then along came Edward Snowden.
Documents leaked by the former National Security Agency contractor, released in the weeks after Biden's visit, ended up enraging Rousseff and completely changing her plans, several Brazilian officials told Reuters.
On Wednesday, she surprised the defense and diplomatic worlds by tapping Sweden's Saab to supply the jets, a move aides said was made in part as a deliberate snub to the United States.
The decision was one of the biggest and most expensive consequences yet of the NSA revelations, which have strained Washington's relations with countries around the world.
Anger over espionage was not the only reason for Rousseff's decision. Saab's Gripen jet offered the best combination of price, transfers of technology to Brazilian companies and low maintenance costs compared with the other two finalists, Boeing and France's Dassault Aviation, Defense Minister Celso Amorim told reporters on Wednesday.
Still, the NSA revelations were clearly the determining factor for Rousseff, the Brazilian officials told Reuters, for reasons that were both political and deeply personal.
A former guerrilla who had fought a U.S.-backed military dictatorship in the 1960s, Rousseff had spent the first two years of her presidency edging closer to Washington, fending off pressure from leftist elements of her Workers' Party and scheduling a rare state visit to the White House for last October.
Snowden's documents, many of which were published by Brazil-based U.S. journalist Glenn Greenwald, revealed that Washington had spied on Rousseff's personal communications, those of state-run oil company Petrobras - which Rousseff once chaired - and countless Brazilian citizens.
Rousseff could not understand why Washington would spy on an ally with no history of international terrorism, aides said. She reacted by canceling her White House trip, despite attempts by U.S. President Barack Obama to ease her concerns, including a one-on-one meeting on the sidelines of a G20 meeting in Russia.
This week, she made a decision she believed would hit the United States where it hurt most - its pocketbook.
Defense analysts struggled to recall a major contract decided on such grounds.
"The irony is that we expected politics to play a big role, but always on the selling side, not on the downside," said Richard Aboulafia, an aerospace analyst with the Teal Group. "Then things went horribly wrong with this NSA story."
A DECADE-OLD SAGA
The final decision on the jets contract had not been expected until next year, so the bidding companies were surprised when it was announced. Brazilian military leaders said publicly that Rousseff informed them of her decision this week.
At a time when the United States and European countries are tightening their defense budgets, the contract was considered a particularly lucrative prize.
For French, Swedish and U.S. diplomats in Brasilia, pushing for the deal had been near the top of their agendas for more than a decade.
In 2009, Rousseff's predecessor, Luiz Inacio Lula da Silva, said Brazil would choose Dassault's Rafale fighter jet. But negotiations over price and transfers of technology - particularly important to Brazil, which wants to increase its geopolitical influence by building a homegrown defense industry - never resulted in a deal.
Shortly after Rousseff took office in January 2011, she surprised Republican Senator John McCain when he visited Brasilia by bringing up Boeing's bid and saying she thought its F/A-18 was the best of the three jets, according to two people who were in the room.
Boeing particularly appealed to Rousseff, people familiar with her thinking said, because the company has a growing relationship with Embraer SA and the jet deal would advance the Brazilian planemaker's technological know-how.
And unlike some hard-liners in her party, Rousseff believed in the importance of the United States as a trade partner that could help Brazil with its first-world aspirations.
U.S. diplomats worked hard to follow up, excited not only about the price tag but also the possibility of a strategic deal with a rising power that at times has seemed closer to U.S. antagonists in the region such as Venezuela and Cuba. Because of the extensive maintenance required and the technology transfers, big aircraft deals can bind companies and militaries together for decades after a deal is signed.
Obama visited Brazil in 2011, Rousseff went to the White House in 2012, and the jets deal was discussed at length by the leaders during both trips. But it wasn't until Biden's visit in May that Boeing was finally on the verge of winning the deal, Brazilian officials said.
Rousseff remained concerned that the U.S. Congress, especially Republican Party members who are traditionally skeptical of leftist governments in Latin America, could block the technology transfers on national security grounds even after a deal with Boeing was signed.
But Biden, based on his 36 years of Senate experience, offered Rousseff a detailed and convincing explanation of why that wouldn't happen, said Brazilian and U.S. officials who were present.
In comments after the meeting, Biden made it clear where U.S. priorities were: "We're ready for a deeper, broader relationship across the board on everything from the military to education, trade and investment."
Boeing executives, U.S. diplomats and even Brazilian officials were exuberant. The expectation, confirmed by Rousseff's aides, was that she would likely announce her choice of Boeing in October, when she was due to make the first formal state visit to Washington by a Brazilian leader in nearly 20 years.
IT ALL FELL APART
The optimism began to fade just five weeks later, when the first Brazil-related NSA documents were released. Then, on September 1, when a report said Rousseff herself had been a target, it became clear that all bets were off and that the Boeing bid was in severe danger.
The day after that report, a person who had been pushing for Boeing angrily questioned whether the intelligence obtained from Rousseff's communications justified possibly losing the deal. "Was that worth $4 billion?" the person asked rhetorically, speaking on condition of anonymity.
Facing renewed pressure from her party's anti-Washington flank, Rousseff requested an apology from Obama, still hoping to salvage the trip. Instead, Obama said only that he would order a review of U.S. intelligence-gathering techniques.
It wasn't enough.
Rousseff announced on September 17 that she was canceling the state visit. Her aides told Reuters that day that Boeing was likely now out of the running.
Still, things got even worse.
Upon new revelations in October that German Chancellor Angela Merkel had her BlackBerry spied on by the NSA, Rousseff and members of her team saw Washington's response as much more contrite, officials close to the Brazilian president said.
Ironically, U.S. officials, when pitching the jets deal to Rousseff, had said Brazil could expect to be a strategic ally on the level of Germany - making the perceived double standard that much more upsetting in the minds of Brazilian officials.
Ben Rhodes, a White House national security adviser, told Reuters in October that it was unclear whether the United States could resurrect Boeing's chances of winning the jets deal.
"We will have to do work, frankly, to put the U.S.-Brazil relationship on a stronger footing on the other end of this," he said.
As 2013 drew to an end, Rousseff's anger lingered, aides said. Meanwhile, time was running out for her to make a decision before yearend. Waiting until 2014, an election year in Brazil, would have increased political scrutiny of any deal.
So she decided to choose a winner this week.
Boeing was out, and the Rafale was by far the most expensive of the three jets, aides said. That left the Gripen, which some elements of the Brazilian Air Force had been pushing for all along. Many defense analysts said that, independent of the politics, it was a solid choice.
"Sweden is a non-aligned state and ticks all the right boxes and will have offered a good industrial package," said Douglas Barrie, senior fellow for military aerospace at the International Institute for Strategic Studies in London.
(Additional reporting by Brad Haynes in Sao Paulo, Tim Hepher in Paris and Andrea Shalal-Esa in Washington; Editing by Paulo Prada, Kieran Murray and Douglas Royalty)