The family lived in a poor neighborhood of Stockholm. Allan had to sell Christmas cards on the street to get money for a violin. He taught himself how to play. He entered the Royal Conservatory of Music in 1930. Finally, he won the Jenny Lind Scholarship in 1930, using it to study viola in Paris with Maurice Vieux. He continued his education as a composer while holding down a job as violist in the Stockholm Concert Society Orchestra, and played in various radio ensembles. His composition teachers were Otto Ohlsson and Karl-Birger Blomdahl. During the 1940s he wrote his important large-scale cycle, Barfotsånger (Barefoot Songs). In another parallel with Mahler, he frequently used melodies from it in his symphonies. In 1943 he married Gudrun Gustafsson. In 1946 they moved into a small fifth floor apartment in the south side of Stockholm. It remained their home for 30 years, becoming Pettersson's prison. In 1950 Pettersson committed himself to prepare for a career entirely devoted to composition. The orchestra gave him leave to study in Paris with Honegger, Milhaud, and Leibowitz. He rejected the neo-Classicism of the first, and the 12-tone proselytizing of the last-named of these. His long, difficult works failed to attract much enthusiasm at home, but he went through with his plans to resign from the orchestra in 1952. Soon, though, he began suffering joint pains that would later be diagnosed as rheumatoid arthritis. Somehow, Sweden's democratic welfare state failed to provide him with needed medical care, medications, or social support. Pettersson described himself as "a voice crying out, drowned in the noise of the times." For a decade and a half he was known as a composer only in narrow circles, though he received a few commissions. In 1963 a recording was made of one movement of one of his concerti for strings. In 1964 the government granted him a guaranteed income. Then he scored his breakthrough with the Symphony No. 7. This one-movement work depicts a harsh inner struggle, relieved by a radiant Adagio section. Antal Dorati's premiere of it on October 10, 1968, was a triumph. It was the last concert Pettersson would attend. Soon, his debilitation made it impossible to descend the stairs. He was trapped in his apartment. Pettersson's only outside view was of a junkyard. He composed his music while a hostile neighbor blasted out rock & roll, often around the clock.
The Seventh Symphony led to international success. Pettersson received commissions for new works, and wrote a new symphony nearly every year. In 1976 the government moved him to a luxurious, ground-level apartment, and provided first-class medical care for him. He died while working on his Seventeenth Symphony. He left 15 extant symphonies and a formidable Second Violin Concerto in a single 50-minute movement.