A gunman was carrying about 100 rounds of ammunition in five magazines when he set out on a bloody rampage through a Brooklyn apartment, killing two brothers who played in an Iranian indie rock band and another musician, police said Tuesday.

Ali Akbar Mohammadi Rafie fired several rounds early Monday before he used his rifle to kill himself on the roof the apartment building where four members of the band Yellow Dogs lived together, police said. Afterward, investigators recovered 81 unfired rounds, some of them in magazines stashed in a guitar case found on an adjoining rooftop.

Records show the Spanish-made assault weapon was purchased by someone else at an upstate New York shop that went out of business in 2006, said Police Commissioner Raymond Kelly.

"We don't know precisely how Rafie obtained it," Kelly said.

Investigators believe the shooter was upset about being kicked out of the Free Keys, another Iranian band with close ties to the Yellow Dogs. Kelly described him as "despondent" about no longer being in the band.

A fourth man was still hospitalized with arm and shoulder wounds, police said.

The two slain members of the Yellow Dogs were brothers Arash and Soroush Farazmand. Two other members weren't home at the time of the bloodshed and weren't harmed.

The row house in the industrial neighborhood of East Williamsburg where the victims lived had been a hangout for artists who attended parties there. The musicians all knew one another, a band manager said.

Originally from Tehran, the Yellow Dogs were the subject of a 2009 film, "No One Knows about Persian Cats," which told the semi-fictional tale of a band that played illegal rock shows there. After coming to New York, the group played at small but hip venues like the Knitting Factory and Brooklyn Bowl.

"They were great kids who people just loved," said the manager, Ali Salehezadeh. "They looked cool and they played great music. ... They wanted to be known for their music."

The third man killed was identified as Ali Eskandarian, an Iranian-American singer-songwriter who had been living in the apartment above the Yellow Dogs.