Following Black Sabbath's 1972–1973 world tour in support of their album, Vol. 4, the group returned to Los Angeles to begin work on its successor. Pleased with Vol. 4, the band sought to recreate the recording atmosphere, and returned to the Record Plant Studios. The band rented a house in Bel Air and began writing in the summer of 1973 but, due in part to substance abuse and fatigue, were unable to complete any songs. "Ideas weren't coming out the way they were on Vol. 4 and we really got discontent," guitarist and songwriter Tony Iommi said. "Everybody was sitting there waiting for me to come up with something. I just couldn't think of anything. And if I didn't come up with anything, nobody would do anything." In 2013, bassist Geezer Butler told Mojo magazine that after the tour in support of Vol. 4 the band was "absolutely, completely exhausted" and by the time they played the Hollywood Bowl, "Tony collapsed. It was really touch-and-go at one point whether he'd survive or not because he was totally depleted. So we had to cancel the rest of the tour and we actually took time off for the first time since the band started. We got away from each other and had a social life. Then we came back together to start on the next album, and couldn't come up with anything." In his autobiography I Am Ozzy, singer Ozzy Osbourne states that in the time leading up to the Hollywood Bowl "Tony had been doing coke literally for days – we all had, but Tony had gone over the edge. I mean, that stuff just twists your whole idea of reality. You start seeing things that aren't there. And Tony was gone. Near the end of the gig he walked off stage and collapsed." Regarding his writer's block, Iommi admitted to Phil Alexander in 2013, "I panicked because I didn't have a single idea about what to write. It might have been the drugs, it could have been the pressure, but either way I felt it was my fault." The band were also disappointed to discover that the room they had used previously at the Record Plant had been replaced with a "giant synthesizer" by Stevie Wonder, who had recently recorded there.
After a month in Los Angeles with no results, the band opted to return to the UK, where they rented Clearwell Castle in The Forest of Dean, Gloucestershire, England, which the likes of Led Zeppelin, Mott the Hoople and Deep Purple wrote and recorded in. The medieval surroundings may have revitalised the band musically, but also left a sinister impression; in the liner notes to the 1998 live album Reunion, Iommi recalls, "We rehearsed in the armoury there and one night I was walking down the corridor with Ozzy and we saw this figure in a black cloak ... We followed this figure back into the armoury and there was absolutely no one there. Whoever it was had disappeared into thin air! The people that owned the castle knew all about this ghost and they said, 'Oh yes, that's the ghost of so and so. We were like 'What!?'" Adds Butler: "We rehearsed in the dungeons and it was really creepy but it had some atmosphere, it conjured up things, and stuff started coming out again". While working in the dungeon, Iommi stumbled onto the main riff of "Sabbath Bloody Sabbath", which set the tone for the new material. In 2001 Butler admitted to Dan Epstein of Guitar World, "We almost thought that we were finished as a band ... Once Tony came out with the initial riff for 'Sabbath Bloody Sabbath' we went 'We're baaaack!'" The spooky atmosphere at Clearwater Castle perfectly complemented the band's practice of playing practical jokes on one another. In the documentary Black Sabbath, Volume 1: 1970–1978 Iommi recalls, "I've got to be honest, we frightened the life out of each other. We had to leave in the end, everybody terrified of each other because we were playing jokes on each other and nobody knew who was doing it... We used to leave and drive all the way home and drive back the next day. It was really silly." In his autobiography Osbourne cracks, "We weren't so much the Lords of Darkness as the Lords of Chickenshit when it came to that kind of thing ... We wound each other up so much none of us got any sleep. You'd just lie there with your eyes wide open, expecting an empty suit of armour to walk into your bedroom at any second to shove a dagger up your arse." Osbourne also writes that he nearly burned the castle down one night when he fell asleep with his boot in the fire. Osbourne said that when it came to the shenanigans Bill Ward typically "got the worst of it", with the drummer eventually going to bed at night with a dagger.
Although the band's then-manager Patrick Meehan received credit as co-producer, Iommi said years later that Meehan had virtually no actual involvement in the album's production, saying "Meehan's ego got involved, and he stuck his name down as producer". Recording was completed at Morgan Studios in Willesden, North London in 1973. Keyboardist Rick Wakeman of the band Yes (who were recording Tales from Topographic Oceans in the next studio) was brought in as a session player, appearing on "Sabbra Cadabra". Wakeman refused payment from the band and was ultimately compensated with beer for his contribution. Allom used phasing effects at the end of "Sabbra Cadabra" to conceal Osbourne's foul language. The members of Led Zeppelin, close friends of the band from their early days in Birmingham, showed up at the studio during Sabbath Bloody Sabbath's recording. Drummer John Bonham was eager to play on "Sabbra Cadabra" but Sabbath preferred to play material other than their own for the occasion. In the end, the two bands had an improvised jam session which was recorded but never released.
Osbourne has said that Sabbath Bloody Sabbath was "the beginning of the end" for Black Sabbath's original line-up. In 2013, the singer elaborated to Mojo, "Sabbath Bloody Sabbath was really the album after which I should have said goodbye because after that I really started unravelling. Then we ended up falling out of favour with each other." Fuelled by rampant drug and alcohol use within the band, tensions began to mount. Iommi began to resent doing the lion's share of songwriting and studio work, thus having no social life. Bassist Butler also began complaining that vocalist Osbourne had become too reliant on him for lyrics.