Peruvian President Pedro Castillo dissolved the nation's Congress on Wednesday and called for new legislative elections, beating lawmakers to the punch as they prepared to debate a third attempt to remove him from office.

Castillo also installed a new emergency government, and called in a televised address for the next round of lawmakers to develop a new constitution for the Andean nation.

Meanwhile, he said he would rule by decree, and ordered a nightly curfew starting Wednesday night.

Castillo also announced that he'll make changes in the leadership of the judiciary, police and constitutional court.

PERU POLLUTION PROTEST: 10 AMERICANS ON TOURIST RIVERBOAT HELD HOSTAGE, RELEASED

Peruvian President Pedro Castillo sitting a table with a mic

FILE - Peruvian President Pedro Castillo gives a press conference at the presidential palace in Lima, Peru, Oct. 11, 2022. On Wednesday, Dec. 7, 2022, Castillo faces a third impeachment attempt by Congress. (AP Photo/Martin Mejia, File) (AP Photo/Martin Mejia, File)

Castillo took action hours before Castillo's opponents in Congress moved toward a third vote to remove him from office, claiming he’s shown a "permanent moral incapacity" to lead the Andean nation. It wasn't clear if they had the 87 votes among 130 lawmakers necessary to remove him.

Castillo said in an unusual midnight address on state television ahead of the vote that he would never stain "the good name of my honest and exemplary parents, who like millions of Peruvians, work every day to build honestly a future for their families."

The peasant-turned-president said he’s paying for mistakes made due to inexperience. But he said a certain sector of Congress "has as its only agenda item removing me from office because they never accepted the results of an election that you, my dear Peruvians, determined with your votes."

Castillo, whose government began in July 2021, denied the allegations against him, saying they’re based on "hearsay statements by people who, seeking to lighten their own punishments for supposed crimes by abusing my confidence, are trying to involve me without evidence."

BIDEN'S VENEZUELA GIVEAWAY FUNDS DICTATORSHIP AND HURTS US ENERGY PRODUCERS AND CONSUMERS

Politicians standing in the Peruvian Congress

Lawmakers stand inside Congress on the day of their planned impeachment vote on President Pedro Castillo in Lima, Peru, Wednesday, Dec. 7, 2022. (AP Photo/Guadalupe Pardo) (AP Photo/Guadalupe Pardo)

Federal prosecutors are investigating six cases against Castillo, most of them for alleged corruption, under the theory that he has used his power to profit from public works.

The power struggle in Perú’s capital has continued as the Andes and its thousands of small farms struggle to survive the worst drought in a half-century. Without rain, farmers can’t plant potatoes, and the dying grass can no longer sustain herds of sheep, alpacas, vicuñas and llamas. Making matters worse, avian flu has killed at least 18,000 sea birds and infected at least one poultry producer, endangering the chicken and turkeys raised for traditional holiday meals.

The government also confirmed that in the past week, the country has suffered a fifth wave of COVID-19 infections. Since the beginning of the pandemic, 4.3 million Peruvians have been infected, and 217,000 of them have died.

Castillo has three times the popularity of Congress, according to opinion polls. A survey by the Institute of Peruvian Studies last month found 86% disapproval of Congress, and only 10% approval. while Castillo’s negative ratings were 61% and 31% approve of his performance.

CUBAN STATE VISIT TO RUSSIA DEMONSTRATES IMPORTANCE OF HAVANA FOR PUTIN'S ANTI-AMERICAN AGENDA

Legislators standing in the Peruvian Congress

Lawmakers stand inside Congress on the day of their planned impeachment vote on President Pedro Castillo in Lima, Peru, Wednesday, Dec. 7, 2022. (AP Photo/Guadalupe Pardo) (AP Photo/Guadalupe Pardo)

There’s a marked contrast in the South American country: While in Lima a majority disapproves of Castillo and wants him out, Peruvians in other cities and rural communities across the interior want him to complete his presidential term, and his promises. Many Peruvians want Congress closed instead.

But with few sure votes in Congress, Castillo hasn’t been able to keep his promises including fighting against corruption, raising taxes on mining, rewriting the constitution and going after supposed monopolies that have raised prices on natural gas and medicines.

The first president to come from a poor farming community in the nation’s 200 year history, Castillo arrived in the presidential palace last year without any political experience. He’s changed his cabinet five times during his year and a half in office, running through 60 different cabinet officials, leaving various government agencies paralyzed.

Although Castillo is the first president to be investigated while still in office, the probes are no surprise in a country where nearly every former president in the last 40 years have been charged with corruption linked to multinational corporations, such as the Brazilian construction firm Odebrecht.

CLICK HERE TO GET THE FOX NEWS APP

Since 2016, Perú has been entrenched in political crises, with congresses and presidents trying to eliminate each other in turn. President Martín Vizcarra (2018-2020) dissolved Congress in 2019 and ordered new elections. That new legislature removed Vizcarra the next year. Then came President Manuel Merino, who lasted less than a week before a crackdown killed two protesters and injured 200 more. His successor, Francisco Sagasti, lasted nine months before Castillo took over.