Oscar Niemeyer, 104, the architect whose soaring buildings form the heart of Brasilia, the instant modernist capital built in the wilds of Brazil in the late 1950s, died Wednesday of a respiratory infection at a Rio de Janeiro hospital.

During his long and productive life, Mr. Niemeyer was revered as well as ridiculed for his daring designs, but the creativity and sheer volume of his works ultimately spoke for him. In 1988, at 80, he shared architecture's biggest prize, the Pritzker.

Mr. Niemeyer, a diminutive, soft-spoken man, worked well into his 90s in a Rio de Janeiro penthouse office with a stunning view of Sugar Loaf Mountain and overlooking Copacabana Beach.

Many of his designs began with a quick sketch that embodied his love of the curve - from Einstein's universe, to the sinewy white beach that he gazed at nearly every day, to the voluptuous women he so loved to watch walking along that beach.

These women, he often said, were his inspiration.

"Curves are the essence of my work because they are the essence of Brazil, pure and simple," Mr. Niemeyer told the Washington Post in 2002. "I am a Brazilian before I am an architect. I cannot separate the two."

A passionate man, he lived in protest of the right angle "and buildings designed with the ruler and the square." His politics were also those of protest - he became a communist in the 1940s because of his anger over the inequality he saw around him, and he was a longtime friend of Cuba's revolutionary, Fidel Castro. His designs - especially of Brasilia - were partly an attempt to push his country toward egalitarianism, bringing rich and poor together through housing projects and public spaces.

A few years after Brasilia was completed, when a rightist military coup in 1964 not only destroyed Mr. Niemeyer's dreams of a just society in Brazil but also took away his sponsors, he fled to Algiers and then Paris. In the city, he had an office on the Champs-Elysees and met Pablo Picasso, Jean-Paul Sartre and many other notables and, he later recounted, lived a hedonistic life far away from his wife, Annita. He returned to Rio in the late 1970s.

Oscar Ribeiro de Almeida de Niemeyer Soares was a Carioca - a native of Rio - whose heritage was Portuguese, Arab and German. Born Dec. 15, 1907, he was the son of a businessman and his wife who lived in Laranjeiras, a quaint, hilly neighborhood within the city.

While at the National School of Fine Arts, from which he graduated in 1934, Mr. Niemeyer worked with architect and urban planner Lucio Costa, who would lead Niemeyer to projects that would make his name in international architecture.

The first Niemeyer structure built was a maternity clinic in Rio in 1937. His first major project, commissioned in 1940, consisted of buildings for Pampulha, a then-new suburb of the southeastern city of Belo Horizonte, including a yacht club, casino and a church so avant-garde in design that church officials refused to consecrate it for 16 years.

With Costa, Mr. Niemeyer also designed the Brazilian Pavilion at the New York World's Fair in 1939, and Mr. Niemeyer influenced the ultimate design of the United Nations headquarters while serving as Brazil's design consultant in 1947.