LONDON/BUENOS AIRES (Reuters) -Argentina's bonds and its currency rallied on Thursday as investors breathed a sigh of relief after the Senate passed a sprawling bill that is key to libertarian President Javier Milei's economic reform plans and renewed a currency swap loan agreement with China.

The Senate win was a major boost for Milei, who won a shock election last year pledging to overhaul the embattled South American country's economy. He wants to privatize public firms, strengthen executive powers and boost incentives for investment.

"Without a doubt it was the best day economically for the government," said Argentine analyst Christian Buteler, citing the approval of the bill, a twin fiscal package also being green-lit and the extension until 2026 of a currency swap line with China.

A currency swap line is a loan agreement between central banks that gives the receiving country access to an agreed amount of funds in foreign currency such as dollars, Chinese yuan or euros.

"The approval of the laws in the Senate, beyond the tightness of the votes or the changes made, underscores the government's ability to govern despite coming into power with a (legislative) minority. That is very positive," he said.

Sovereign bonds in the local over-the-counter market were up an average 2.5%, a sovereign risk index fell sharply, while the black market peso strengthened nearly 4% to 1,240 per dollar after hitting a record low in the past week.

The local S&P Merval stock index, however, dipped after jumping in early trading.

The narrow overnight Senate wins came as protesters set fires and clashed with police in the streets outside Congress, with some citizens fearing it would leave them further exposed to rising unemployment and consumer prices.

Thys Louw, portfolio manager at asset manager Ninety One, said the bill's passage was the first step in a "very tight, very noisy, very long process" ahead.

"It wasn't perfect, but I do think it was a step forward in views around governance and for the ability to govern," he said.

Even so, Argentina is far from out of the woods, analysts cautioned. The lower house still needs to approve individual measures before Milei can officially pass his first law.

"We could see a sustained rebound in the Merval (main stock index) if Mr. Milei's objectives are met and lead to a decline in country risk and a recovery in sovereign bonds," said Andres Abadia, chief Latam economist at Pantheon Macroeconomics. "For now, though, uncertainty remains elevated, so caution is warranted."

(Reporting by Karin Strohecker; additional reporting by Libby George; Editing by Bernadette Baum and Leslie Adler)

By Karin Strohecker and Walter Bianchi