President Daniel Ortega, dismissing U.S. charges of Nicaraguan complicity in terrorism, declared today that the Reagan administration is practicing state terrorism by financing anti-Sandinista rebels in a guerrilla war.

"So who are the terrorists, so who are the terrorists?" Ortega shouted to hundreds of thousands of Nicaraguans gathered in Managua to mark the sixth anniversary of Sandinista rule.

"The lie is the terrorism of North American rulers, which has meant the murders of 199 children under 12 years of age, 166 wounded and 203 kidnaped, a total of 568 children under 12 years of age who are victims of U.S. terrorism. Terrorism is to finance in the name of democracy the mercenaries who have murdered 134 women."

Although he did not say so, Ortega apparently was referring to casualties since the start of the guerrilla war by anti-Sandinista insurgents more than three years ago. In all, Sandinista officials say, more than 12,000 Nicaraguans have been killed, wounded or kidnaped in the conflict.

The U.S. accusations and a threat of reprisal, in a diplomatic note made public yesterday, overshadowed anniversary celebrations that the Sandinista leadership had intended as a joyous demonstration of popular support for the revolutionary government in power here since July 19, 1979. To make its point, the Sandinista National Liberation Front organized transportation to the celebration for people from all around the country, and Ortega said "at least" half a million Nicaraguans gathered in Managua's Carlos Fonseca Park to hear his 45-minute speech.

Sandinista officials said the president had planned a short, folksy address designed to emphasize his popularity with Nicaragua's 3 million inhabitants. But he apparently changed his mind, devoting much of his talk to the terrorism argument to underline official outrage here at the U.S. charges.

Sandinista officials have expressed particular resentment at the Reagan administration's accusations linking them to terrorism because, in their view, Nicaragua has suffered from terrorism at the hands of Central Intelligence Agency operatives and rebels in the Honduras-based Nicaraguan Democratic Front, which has received CIA financing and other aid. A vivid reflection of this resentment appeared in today's progovernment Nuevo Diario newspaper.

"The only thing missing was to accuse us of responsibility for Reagan's cancer," said a headline over a front-page article on the U.S. accusations.

In its note, the Reagan administration said it has intelligence information that the Sandinistas may be directly involved in plans to attack U.S. citizens in neighboring Honduras and warned that if Nicaraguan-supported attacks on Americans are carried out there or anywhere else, the United States will respond "accordingly." The note also accused Nicaragua of indirect responsibility for the June 19 assassinations of six U.S. citizens in El Salvador because of Sandinista backing for the Salvadoran rebels who claimed responsibility for that attack.

Echoing a formal diplomatic note made public by the Foreign Ministry last night, Ortega rejected the U.S. charges and suggested that they were part of a campaign by the Reagan administration to generate an atmosphere conducive to a U.S. attack on Nicaragua.

"Nicaragua has not practiced terrorism, has not supported terrorism and has not been involved in any terrorist act," he said. Instead, he added, U.S. citizens are put into jeopardy abroad by "interventionist" Reagan administration policy.

Ortega challenged the Reagan administration to take its terrorism charges against Nicaragua to the International Court of Justice in The Hague. The Sandinista government has brought action against the United States in the court, accusing Washington of violating international law through CIA-organized attacks on Nicaraguan installations. But the Reagan administration has refused to recognize the court's jurisdiction in matters concerning Central America, an action Sandinista officials see as a victory for them on the international stage.

"We are still waiting for the United States in the International Court of Justice," Ortega declared.

Although U.S. officials repeatedly have declared that the administration has no intention of attacking Nicaragua, Sandinista leaders have been warning for some time that such an attack is likely. A number of PT76 tanks have been dug around Managua in what officials portray as preparation against U.S. soldiers, and today Ortega renewed Sandinista pledges to defend the capital "block by block."

Ortega and the rest of the nine-member Sandinista National Directorate, the country's ruling body, appeared for the observances wearing their olive-green military fatigues. Vice President Sergio Ramirez, who is not among the nine military leaders of the Sandinista Front, wore a safari suit.

Also lending a military accent to the ceremony were a dozen helicopters that flew in formation over the crowd, including several recently acquired MI24 Hind gunships. The powerful Soviet-made gunships have been described as particularly effective against guerrilla forces such as the anti-Sandinista rebels. But rebel leaders say the new aircraft have not been seen yet in combat in Nicaragua.