Mardik Martin, a screenwriter who collaborated with Martin Scorsese on films like “Raging Bull,” “New York, New York” and particularly Mr. Scorsese’s breakthrough in gritty realism, “Mean Streets,” died on Wednesday at his home in Los Angeles. He was 84 .

The cause was complications of a stroke, said Hunter Hughes, his friend and former assistant.

Mr. Martin met Mr. Scorsese when they were both film students at New York University in the 1960s. Obsessed with movies, they began to collaborate.

“For a time, we were inseparable,” Mr. Scorsese said in a statement after Mr. Martin’s death. “We went to see movies together, we talked about them endlessly, and then we started dreaming up the pictures we were going to make — in diner booths and on benches in Washington Square Park, walking the streets of Lower Manhattan or driving around the city, in hot and cold weather, in sunshine and in rain and snow, by night and by day.”

Mr. Martin drew from the seedier side of New York, going to great lengths, he said, to dredge up realistic dialogue for his scripts. “I would drive around and pick up hookers, but not for the sex,” he said in 2007. “I would bring a tape recorder and pay them $100 for their stories.”