The archbishop of Madrid, Cardinal Antonio Maria Rouco Varela, pronounced the couple husband and wife at Almudena Cathedral in what was Spain's first royal wedding in 98 years. Previous weddings took place abroad.
Just one year after she started dating the prince, Ortiz, a 31-year-old divorcee, now has the title of Princess Letizia of Asturias.
In his homily, Rouco Varela urged the couple not to be intimidated by the enormous responsibility of being heirs to the Spanish throne.
"Fear not these extraordinary demands," he said. "You are not alone in your path. Their majesties the king and queen of Spain, the royal family, your relatives and loved ones, the good people of Spain, are with you."
The congregation of some 1,400 royals and other dignitaries included Britain's Prince Charles, former South African President Nelson Mandela and Jordan's Queen Rania.
The prince met Ortiz at a dinner party in late 2002 and they started dating secretly the following spring. Word of their engagement in November took the country by surprise, though polls suggest Spaniards don't mind that Ortiz is a divorcee and has no royal blood.
Torrential rain fell as Ortiz entered the church, and thunder sounded during the wedding Mass. She wore an off-white gown with a flowing silk veil and a 4.5-meter (15-foot) train embroidered with heraldic symbols. Her diamond and platinum tiara was the same one Greek-born Queen Sofia wore at her wedding to King Juan Carlos in 1962 in Athens. Her bouquet was an arrangement of white lilies of the valley.
Prince Felipe, 36, wore a crisp blue uniform reflecting his status as a Spanish army major, with braided epaulets, a light blue sash and medals of honor from the army, navy and air force.
There were a couple of slip-ups, mainly in the re-enactment of a centuries-old custom in which the bride and groom exchange coins as symbols of the possessions they will share.
Rouco Varela dropped a few of the 13 gold coins - some 500 years old - as he handed them to the prince. The prince then forgot his lines as he addressed Ortiz, and had to look down at notes on a stand in front of him.
The rain stopped in time for the newlyweds' procession through the streets of Madrid in a vintage, black armor-plated Rolls-Royce. They waved to tens of thousands of well-wishers holding small red-and-yellow Spanish flags. A line of policemen stood at attention, keeping the crowd behind barriers.
People crowded on balconies of nearby buildings to catch a glimpse of the couple.
"If I could, I would open a bottle of champagne and offer them a toast. I wish them lots of luck," restaurant owner Santos Sanchez said.
The motorcade rode past the "Forest of the Absent," a grove of potted olive and cypress trees honoring those killed in the March 11 terrorist attack in Madrid. The train bombing killed 191 people, and one policeman was killed trying to arrest Islamic militant suspects.
The procession ended at a church where Ortiz, honoring Spanish royal tradition, left her bouquet to pay homage to a statue of the Virgin Mary.
Security for the wedding has been described as the tightest since Madrid hosted a Mideast peace conference in 1991. An estimated 20,000 police patrolled the streets, and F-18 fighter jets and two AWACS planes on loan from NATO monitored the skies.
The city was festooned with Spanish flags and thousands of geraniums, tulips and other flowers. It was welcome relief for a country still mourning the terrorist attacks.
The ceremony was the first royal wedding in Spain since that of the prince's great grandfather, King Alfonso XIII, in 1906. The prince's father, King Juan Carlos, and grandfather, Juan de Borbon, married abroad during the dictatorship of Gen. Francisco Franco.