The leaders say the pact ushers in a new era of co-operation
Brazil has agreed to triple its payments to Paraguay for energy from a massive hydro-electric dam on their border, ending a long-running dispute.
Under the accord, Brazil will pay Paraguay $360m (£220m) a year for energy from the jointly-operated Itaipu plant, one of the biggest in the world.
Brazilian President Luiz Inacio Lula da Silva called it a "historic agreement" after talks in Paraguay.
The deal is a political victory for Paraguayan President Fernando Lugo.
His left-wing government had campaigned on an election promise to gain more revenue from the plant.
Under the deal, Paraguay has also won the right to sell excess energy directly to the Brazilian market, rather than exclusively through the state-owned power utility Eletrobras.
The joint project was begun in the 1980s when both countries were under military rule.
Paraguay - one of the poorest countries in South America - only uses a 5% share of the electricity produced at the plant and said it was obliged to sell its surplus to Brazil at unfair prices.
The Brazilians argued that they covered most of the cost of constructing the vast project, and that their smaller neighbour had to pay its fair share.
The deal came after months of wrangling between the two sides, but could still face criticism from opposition leaders in Brazil, analysts say.