Mireya Moscoso was sworn in as the first female president of Panama today, four months before this tiny Central American nation is to take control of the Panama Canal.

Moscoso, holding the hand of her adopted son, took the oath of office almost three hours later than scheduled as legislators electing the president of the national assembly engaged in last-minute power brokering. Moscoso's fragile parliamentary majority withstood an opposition challenge, and her alliance's candidate, Enrique Garrido, was elected assembly president.

Once the squabble ended, Moscoso replaced Ernesto Perez Balladares, who has been president of Panama since 1994.

The ceremony took place at the national stadium before almost 25,000 supporters bused in from all over the country. Representatives from more than 40 countries also attended, including Buddy MacKay, U.S. special envoy to the Americas, and presidents from Venezuela and Central America.

Moscoso, the 53-year-old widow of three-time Panamanian President Arnulfo Arias, will lead her country as the United States withdraws its forces and hands over the Panama Canal by the end of this year, as agreed in a 1977 treaty.

"Next December 31, at noon, we will have finally and forever achieved our true independence," she told the crowd.

Moscoso won the May election with 45 percent of the vote, defeating Martin Torrijos, son of the late military strongman Gen. Omar Torrijos. She pledged to fight poverty and unemployment in this country of 2.7 million people.

Moscoso, a teacher's daughter from the agricultural heartland, has never held elective office. But after her husband's death in 1988, she assumed increasing prominence in the Arnulfista Party named for him.

She was a dark horse candidate for president in 1994, coming in second to Perez Balladares with 28 percent of the vote. Now she must turn her attention to the Panama Canal Zone on either side of the waterway, which connects the Atlantic and Pacific oceans and has been under U.S. control since 1903.

While foreign governments will closely watch how Panama runs the canal, the United States is likely to pay as much attention to Panama's ability to police its southern frontier with Colombia, where guerrilla incursions are frequent. Sources in the military say the U.S. anti-drug effort is also suffering from the closing of Howard Air Force Base.