Frederick Loewe, 86, a European-born musical prodigy who infused his lively rhythms into the American lifeblood as the composer of "My Fair Lady," "Brigadoon," "Camelot" and other Broadway and Hollywood musical classics, died yesterday at a hospital in Palm Springs, Calif.

Paired with the late Alan Jay Lerner, who wrote the words to Mr. Loewe's music, the composer set a nation and much of the world to humming such tunes as "The Rain in Spain," from "My Fair Lady," "If Ever I Should Leave You" from "Camelot," and "Gigi" from the film of that name.

Mr. Loewe, who had a severe heart attack in 1958, died at Desert Hospital shortly before 2 p.m. The cause of death was not immediately available.

He had been taken to the hospital Wednesday after experiencing chest pains and difficulty in breathing.

The American musical theater has been described as one of the nation's principal contributions to world culture, and Mr. Loewe and his collaborator were ranked among the foremost contributors to that theater. Many of their songs and more than one of their shows are regarded as masterpieces.

If there were any qualities that seemed to typify Mr. Loewe's work, they may be a punchy vigor and a spirit-lifting exuberance. These lighthearted qualities seemed characteristic of Mr. Loewe himself, and of the "Old Vienna" musical milieu from which he came.

He was born June 10, 1901, the son of Edmund Loewe, a tenor famed for his operetta performances. The father had created the role of Prince Danilo in Lehar's "The Merry Widow."

The son took piano lessons at 5. At age 9 he composed tunes for a music hall sketch for his father. A piano soloist with great European orchestras at 13, he wrote a popular song at 15 that sold 2 million copies.

But when the son arrived in this country in 1924, he gave a concert in New York that led to no new bookings.

That proved the prelude to years as a musical nomad, in which he performed in movie theaters, nightclubs and beer halls and on cruise ships.

There were also stints of teaching horseback riding, cleaning restaurant tables, delivering mail and even prospecting for gold in the West.

The composer won eight consecutive bouts as a flyweight and bantamweight boxer in Brooklyn, N.Y., at $5 a bout. A ninth, losing bout ended that phase of his career.

In 1935 one of his songs was bought for a musical play. His musical, "Salute to Spring," was staged in St. Louis two years later. "Great Lady," another musical, reached Broadway in 1938 but closed after 20 performances.

A second attempt to make a career as a concert pianist failed in 1942 at Carnegie Hall. It was a turning point.

At New York's Lambs Club, a theatrical gathering place, Mr. Loewe was offered the opportunity to write the music for an out-of-town musical. There was a two-week deadline, but he knew he could meet that.

It was also necessary to find a collaborator to write the book and lyrics.

At the club, he looked around and saw Lerner. Lerner had written material for a club revue. Mr. Loewe introduced himself.

Their "Life of the Party" ran in Detroit for nine weeks. In 1943, the pair landed on Broadway with "What's Up?" and they returned in 1945 with "The Day Before Spring."

Two years later came "Brigadoon," their first major hit, which was followed by "Paint Your Wagon" in 1951.

Five years later, they won their place in the history of popular entertainment with "My Fair Lady," which exhausted the critics' supply of superlatives, ran longer than any previous Broadway musical, and in all its incarnations grossed nearly $1 billion.

The team wrote the songs for the hit 1958 movie "Gigi," which won nine Oscars, including one for the title song.

But after they collaborated on "Camelot," which opened on Broadway in 1960, the team broke up.

Working together, once fun, had become onerous and burdensome, filled with acrimony and angry silences.

The two, it was explained, were opposites by nature -- Lerner meticulous and analytical; Mr. Loewe, effusive, instinctive and uninterested in reworking and revising.

In part, also, Mr. Loewe's health problems made him less able to offer the energy that the collaboration demanded.

But in time, they joined forces again, in particular to adapt "Gigi" for a 1973 Broadway opening.

In 1979 at a gala in their honor, Lerner said of Mr. Loewe: "There will never again be another Fritz . . . . Writing will never again be as much fun . . . . I loved him more than I understood and misunderstood him, and I know he loved me more than he understood or misunderstood me."

Mr. Loewe and Lerner, who died in 1986, received the Kennedy Center Honors for lifetime achievement in the arts from President Reagan in 1985.

Mr. Loewe was married in 1931 to Ernestine Zerline; they divorced in 1957.