I was the watch manager at a local station of the Berlin fire department that Friday, 15 December 2017. We got an alert around 8.25pm and rushed to the fire engine, where the printout from the dispatcher said there was a nine-year-old boy locked in a safe. Information sometimes gets lost over the phone, so I was doubtful. I was thinking, “It’s just going to be a cupboard that looks like a safe.” But I had to be prepared for everything.

I asked myself: if it were a safe, would it be airtight? I was aware it might already be too late by the time we arrived. I had to plan for a tragic outcome. On the other hand, if we were in time, how long would it take us to open the safe? I knew it would be an incredibly difficult task. It’s what safes are designed for – not to be opened.

It took less than five minutes to reach the property, a family home in south-west Berlin. I was still hoping this was nothing, but when I saw a woman crying on the street, I knew the situation was serious. She was the boy’s mother and she led us into the basement, where his father was waiting by the safe. He told us the boy was alive and we started talking to him; he was very calm. We asked how it had happened: during a game of hide and seek with his five-year-old brother, he had thought the safe would be a good place to hide.

The boy’s parents had inherited the house from his mother’s father. The unlocked safe had been there when they moved in and was in an area they didn’t use much. The boy’s little brother had shut the safe, then, when he couldn’t open it again, had gone upstairs and told his mum. She had followed him to the basement and called us immediately. The only person who knew the combination was the boy’s late grandfather.

From the outset, the biggest priority was getting oxygen to the boy. All the experts we were calling told us the safe was airtight and he was going to die. We put a light to the door of the safe and moved it, and he told us where he could see it, so we knew there was a paper-thin gap. We got oxygen from the paramedics and put a small tube against the gap. The boy said that he could feel a thin stream of air.

Next, we had to work out the combination: blindly opening the safe by force might have hurt or suffocated the boy. I asked his parents if anyone had opened the safe before and they said no. So we had to guess a six-digit code. We moved the safe away from the wall; behind it we found some papers and a manual, which had several codes written on it. We started typing them in – but we had to wait 10 minutes between each attempt before we could try again.

While we were doing this, the boy’s mother remembered that her brother had once opened the safe, so when the codes we had didn’t work, she called him. He gave us six birth dates and anniversaries to try.

By this time we had worked out a way to reduce the 10-minute pause between punching in codes to just one minute, so quickly we tried them all. No luck.

We were fully prepared at this point to open the safe by force, starting with a drill. We taught the boy to put his hands over his ears while we drilled, and to take them off only when we shook the safe; then we cut a hole in the back. It was dangerous, but I was confident that we could get him out.

Then, just as we started to make the first cut, my colleague punched in the correct code. We’d asked the mother again to write down any significant dates and it turned out to be her brother’s birthday. We were amazed.

We had been trying for three hours and now all of a sudden this little boy was standing in front of me, rubbing his eyes. He had been so calm the whole time, following our commands and talking to us, and his parents were so happy that he was out. He had a cuddle with his tearful mother, a checkup from the doctor, and then went for a shower – he was sweaty and his clothes were wet from breathing in that tiny space for so long.

Driving home, I was so proud of what we had achieved. I remember thinking: “This might be the greatest thing you’ll ever do in your job.” It was incredible teamwork.

Hopefully the boy will be more careful next time he plays hide and seek – but at least we know the combination to the safe now.

• As told to Sophie Haydock

Do you have an experience to share? Email experience@theguardian.com