As the seventies wore on, the core members of Steely Dan—Donald Fagen and Walter Becker, who died this month at 67—became as well-known for their studio perfectionism as they were for their songs. The band recorded take after take after take, and relied on a revolving door of top musicians who would be replaced if the band wasn’t pleased with the sound. It was an odd, neurotic approach that turned the creative pair into musical auteurs of sorts, but made finishing a record nearly impossible. With 1977's Aja, though, it resulted in a remarkable distillation of the band's ornate jazz-pop vision.

Dan fans pore over individual solos the way religious scholars study scripture. This is the inside story of Steely Dan’s relentless quest for one legendary guitar solo. The song in question was “Peg,” which appeared on the massive-selling Aja album 40 years ago this week. (These firsthand accounts were provided to Newsweek in the form of phone or email interviews, with the exception of the quotes from Fagen, which are attributed to author Don Breithaupt’s well-researched book about Aja.)

Elliot Scheiner (engineer, worked on Aja): Every track, every overdub, had to be the perfect overdub. They didn’t settle for anything. They were always looking for the perfect.

Steve Khan (guitarist who played rhythm guitar on “Peg”): Having the money, and the power of guaranteed sales, is a license for abuse. What they might waste on one or two days of recording to get a single track, most artists, like me, could make an entire record for that!

Fagen (as quoted in the 33 ⅓ book about Aja): We were free to hire anyone we wanted from any discipline.

Elliott Randall (guitarist/session musician known for his work with Steely Dan): Walter and Donald were always a delight to work with. It was always laughs, and good moods prevailed, while we searched for the “new” and “different.”

Khan: Most of the in-the-studio direction came from Donald. He was often out there with us while Walter and Gary were in the control room… To get a track past all three of them was next to impossible. If two liked it, one would veto it just to exercise his own sense of authority.

Related: How a long-lost Thelonious Monk album was found and released nearly 60 years later

Jay Graydon (guitarist who played the solo on “Peg”): You can make anything perfect in Pro Tools. But back then there was no help, man. Before Pro Tools, there were pros!

In 1977, Steely Dan spent months in the studio recording Aja. They became especially obsessive about the soon-to-be hit single “Peg,” an infectious, funky number that was built meticulously from the drum track up.

Scheiner: When we did things like “Peg,” a band would come in and record and two hours later they'd look at Gary [Katz], their producer, and say, “Fire this band. Let’s go with somebody else tomorrow night.” It'd be different bands every night to get the same song.

Graydon: If anybody takes [being replaced] personally, they're an idiot. You're not gonna make a hundred percent of people happy. I got dumped on a solo on a Boz Scaggs album because the producer could get Carlo Santana.

Khan: For that entire session, no one (Donald, Walter and Gary) said a single word to me. Nothing! I knew that they were famous for erasing people. I was fully expecting to be erased! At one point, I went into the control room and quietly said to Elliot [Scheiner] "Is what I'm playing working? Do you they like what I'm doing?" To that Elliot said,  "Yes! They love it! They would have said something to you if it was not working.” I still left the studio thinking they were going to erase everything.

Scheiner: They just wouldn't settle for anything. It was either great or it wasn't.  

Khan: They said, “Hey. Do you have anything you can do to spice up the intro? Like a sound, something.” I said, “OK.” When you’ve been recording long enough, one of the first things you learn to do is you just say yes to everything... So I pulled out this MXR Flanger. I’d never done this on anything before and I never did it again, because it’s such a tasteless sound. I just turned the regeneration knob all the way up. That’s the sound you hear: [imitates the flanger sound during the song’s intro]. I totally expected them to say, “Are you crazy? Turn that shit off.” But for some reason they liked it!

The song called for a guitar solo after the first chorus. But when it came time to record the solo, Steely Dan’s insatiable perfectionism took over. According to some accounts, the band had as many as seven or eight skilled guitarists try soloing over the track before recording a take they were satisfied with. (Becker, in an old video interview, said it was “six or seven” players.) Engineer Scheiner, who puts the number at five, says it took an entire week to get that one guitar solo.

Fagen (as quoted in the 33 ⅓ book about Aja): It was just a blues with that one change-up you had to watch. We were amazed that it was so hard to get someone to do a comfortable-sounding solo over it.

Scheiner: The first one to overdub was Walter [Becker]. And he didn't like it. He was pretty fussy about how we wanted it to sound. After that, they went with… he was a blues guitar player. I don't remember his name.

Fagen: Walter tried it first. I liked what he did, as I recall, but he didn’t… So we started calling guys. We figured, well, let’s have Robben Ford come in and do it, and it’ll be done. I don’t know if he was nervous, but Robben kept playing these furious solos, which is not really like him—he’s usually pretty relaxed. I didn’t hear any central idea in what he was playing, so we tried to give him a few ideas and it just wasn’t happening.

The hunt for the elusive solo dragged on. Among the players who were brought in to give it a try: Steely Dan vet Elliott Randall (who’d played the "Reelin' in the Years" solo) and former McCoys singer Rick Derringer. Fagen and Becker still weren’t satisfied. To make matters worse, Randall says his beloved Fender amp was stolen from A&R studios during the session.

Rick Derringer (guitarist/producer who tried his hand at the “Peg” solo): One day I got a call from Gary [Katz, producer]. He said, “We're working on a possible next single. We’d like you to come in and play the guitar solo on that song.” I said, “That’s great, thanks, man!” I worked with them for a while. They were very happy with what they had happen.

Randall: There were five of us who interpreted the solo section. I'm sure that each of us walked away feeling really good about it. To be honest, I don't think I could remember the content of [my] solo even under hypnosis.

Fagen: We brought in four or five guys. There was a guy whose name I can’t remember, who was more of a jazz guitarist. That guy almost made it, but it reached a certain point and then there was no peak. We were embarrassed for them and for us. We felt silly spending all this money for this one brief blues solo.

Randall: Instruction? What instruction? The only constant for that would be Walter coming over to me right before the assistant hit the red button [and saying], “Play the blues, Elliott.”

Derringer: I was one of the first guys in line to get that single when it came out. I wanted to hear the solo I played. I put it on and it wasn't me! For a couple years, I thought, “Oh man, I guess the solo wasn't what they wanted.” I spoke later to Gary Katz and Gary told me, no, nothing like that at all. What actually happened was the recording got degraded and the solo was messed up. Something screwed up technically.

Scheiner: Rick Derringer was there for about three or four hours. We got something out of him. The minute he left, Walter looked at me and said, “Erase it.” I said, “OK.” You never questioned it. You didn’t say, “Come on, really?” It was over.

Derringer: I was relieved to hear it was just a technical issue.

Scheiner: They tried to get what they wanted out of Rick. And didn't get it. So I erased it.

Finally, the band recruited Los Angeles guitarist Jay Graydon. (Graydon tells me he was recommended by an engineer friend; he jumped at the chance to play on a Dan record “because that’s the most musical you can get and still be commercial.”) After hours of work, Graydon recorded the inimitable solo that made the cut.

Graydon: [After hearing Katy Lied], I thought to myself, these guys think like me. Then I heard The Royal Scam and thought, these guys really think like me!

Scheiner: Walter tried again one day but felt it wasn't good enough. They ended up going to L.A. and doing it with Jay Graydon.

Graydon: I found out I was the seventh guy. For about an hour and a half, I’m playing my hip, melodic kind of jazz style. Then Donald says to me, “Naw, man. Try to play the blues.” I’m thinking, if I gotta play blues in this solo, I can’t use a B-flat. Because B is in that chord. I can’t use an F unless it’s running through the chord… So I can make it be a believable seventh chord by using the seventh in part of the line. I play bluesy for a while. I get melodic for a while. I get bluesy again. Then I get melodic and bluesy.

Fagen: We hadn't heard of [Graydon], but he played a lot of sessions. He came in and essentially knocked it off, as I recall.

Graydon: The whole thing probably took about four, five hours. Including taking some breaks. They knew they were onto something… Why did my solo work and the others didn't? They just didn't get the melodic concept that [Steely Dan] wanted. Nobody else got it, I guess. I don't know. I'm not the other guys. To me, it wasn’t difficult. Hey man, I just went for it! I don't care if I crash into a musical brick wall. At least I tried.

Khan: [on hearing the finished solo for the first time] I think I said to myself, “Hmm. Well, that's interesting!” An interesting approach to a tune that's kind of like a blues but with major seventh chords.

Graydon: When I walked out of the studio at the end of the night, I didn't know it was a keeper. I turned the radio on one day, and there it is. I thought, Hey, I made it! I could tell my tone pretty quick. I don't play like anybody else, man.

Four decades later, Graydon has played on thousands of other recordings and won two Grammys, but he is still asked about a 30-second guitar solo he played in 1977. He still works himself to death to get great solos, he tells me, particularly on his collaborative album with Randy Goodrum.

Can you still play the solo?
I relearned it for a [documentary] movie called Hired Gun. I used the same guitar and amp and volume pedal that I used for the original. I relearn it about every two or years for everybody.

There are tons of tutorial videos on YouTube about how to play your solo. Have you seen those?
Everyone I've seen is wrong! Nobody plays it properly. I crack up when I see this stuff. [But] I can't get up in flames, putting people down. I just stay positive. It's not easy to play the first couple of bars. It's a double-stop bend.

What impact has it had on your career?
Believe me, I'm very thankful that this happened. There are so many other moments of my life that are much more important to me musically, but it’s nice [to be recognized]. Even Donald says, “Man, this is one of our most famous solos!” I said, “Let me guess, I know another one is going to be ‘Kid Charlemagne.’”

What do people say to you when they find out you played the guitar solo on “Peg”?
“How in the hell did you play such an incredible solo?” And I go, “I just played!” I can’t explain it any further. I just did what my musical brain told me to do. And my fingers followed.