The Brazilian government and Abbott reached an agreement late on Friday after 10 days of negotiations.
The Health Ministry had warned it would start producing a cheaper, generic version of the anti-retroviral drug Kaletra unless the US manufacturer sharply cut its price for the Brazilian market by midnight on Thursday.
As part of the agreement, Brazil will also have access to Kaletra's new formula, which is expected to be released in two years, the health ministry said in a statement.
In addition, Abbott agreed to transfer technology to Brazil so it can begin producing a generic version of the drug after 2015.
The Health Ministry said Abbott's price reduction will allow Brazil to save $18 million next year, and $259 in six years.
The agreement doesn't specify a per-capsule price, which will be dependent on the number of patients taking the medication. Brazil wanted to lower the price of each pill from $1.17 to $0.68.
The Brazilian government said it will be allowed to expand the number of patients treated with Kaletra without an increase in the drug's annual cost.
In a statement, Abbott said the agreement accomplishes its "objectives of helping Brazil expand patient access to Kaletra while preserving the company's intellectual property rights, which Abbott was not willing to negotiate."
Saraiva Felipe (R) was sworn in as
Brazil's new health minister
The deal comes amid a reshuffling in Brazil's Health Ministry. Saraiva Felipe was sworn in late Friday as the new health minister, replacing Humberto Costa, who had issued the ultimatum to Abbott.
Felipe continued to pursue Costa's policy of seeking cheaper treatment for some 170,000 Aids patients in the country. The Health Ministry estimates that 600,000 of Brazil's 182 million people are HIV positive.
Brazil had justified the move to break the patent by declaring a public health crisis for its anti-Aids programme, which provides free medicines for anyone who needs them.
"The ministry was assured that Kaletra will continue to be provided without any risk," former minister Costa said in a statement. "And at the same time it guaranteed the sustainability of (the anti-Aids) programme."
Brazil currently pays Abbott $107 million annually for Kaletra and could reduce the cost to $54 million by copying the drug, the Health Ministry said.
No legal basis
Abbott insisted it already provides the drug to Brazil at the lowest price outside Africa. The company said Brazil did not have a legal basis to issue a compulsory license, the first step toward breaking the patent under World Trade Organisation rules.
Brazil has repeatedly forced Aids drugs manufacturers to reduce prices by threatening to break their patents but has never taken that step. It is also in similar negotiations with two other makers of Aids drugs - Merck & Co Inc and Gilead Sciences Inc.
Property rights advocates and the pharmaceutical industry had described Brazil's threat as government-sanctioned piracy of intellectual property driven by greed.
Brazil says that in emergency situations, the government can refuse to honour a patent for intellectual property so that a cheaper generic can be made. Other countries have similar laws. Canada and the United States considered breaking patents on some antibiotics during the anthrax scare in 2001.