Presidents from all other Central American nations attended the inauguration, but the one who received the most press attention was Ahmadinejad, who is touring the region to bolster Iran's alliances in Latin America at a moment of sharp confrontation with Washington over Iran's nuclear program.
This is part of a unified process that has been set in motion (in Latin America), because only by being united will we truly be free.
Ahmadinejad said both Iran and Nicaragua are "on the road to fight for the establishment of security and justice" and referred to Ortega as "my brother president."
The Nicaragua stop for Ahmadinejad comes as two assailants on a motorcycle attached magnetic bombs on Wednesday to the car of an Iranian university professor working at a key nuclear facility, killing him and wounding two others, according to a semi-official news agency report. The attack in Tehran strongly resembles earlier killings of scientists working on the country's controversial nuclear program.
The United States and other countries say Iran is trying to develop nuclear weapons technology. Iran denies the allegations, saying that its program is intended for peaceful purposes.
Ortega's closest and most financially supportive ally, Chávez, attended the ceremony after playing host to Ahmadinejad in Caracas.
"This is part of a unified process that has been set in motion [in Latin America], because only by being united will we truly be free," Chávez said of Ortega's re-election. The comment was apparently a reference to the countries in the region which, like Nicaragua, participate in the Chávez-inspired, left-leaning Bolivarian Alliance.
Ortega and Chávez have been staunch defenders of Ahmadinejad, who has come under pressure from U.S. sanctions intended to rein in Tehran's nuclear program.
In his first comments after taking office, Ortega said that "there is an entire conspiracy against Iran," and suggested Ahmadinejad propose "disarming Israel's nuclear stockpile, in order to bring peace to the region."
Both Ortega and Chávez also defended late Libyan dictator Moammar Gadhafi, who was ousted by a popular uprising aided by NATO airpower and killed in October. Ortega said a "brutal crime" was committed when Gadhafi was killed by rebel captors in October.
Ortega, while shrugging off opposition complaints his re-election was illegal and vowing to govern with moderation, took the oath of office in front of about 8,000 people gathered at Revolution Plaza. The plaza was the site where he and his ragtag band of Sandinista rebels celebrated the overthrow of dictator Anastasio Somoza in 1979.
Ortega was a socialist firebrand in 1979 and throughout his first term in the 1980s, and the U.S. government, enmeshed in the Cold War, tried to overthrow him by backing Contra rebels. But he eventually was voted out of office in 1990.
Ortega is still a firm ally of Chávez and Cuba's communist government, but he has worked to maintain ties with Washington. He signed the Central American Free Trade Agreement with the U.S. and has cultivated relations with the Roman Catholic Church and Nicaragua's business sector. He also has boosted his popularity by creating dozens of programs for the poor in a country where more than 40 percent of the people live on less than $2 a day.
Ortega has promised to follow a moderate path in his third term, even though his Sandinista party dominates Nicaragua's legislature.
Still, critics allege he aims to become president for life, using courts and electoral institutions that are stacked with Sandinista appointees. The Supreme Court ruled that Ortega could seek re-election though the country's constitution forbids it.
Despite that controversy, the 66-year-old Ortega won 64 percent of the vote in November, though opposition parties allege that total was inflated by fraud.
Based on reporting by the Associated Press.