"Red Army soldiers don't believe in 'individual liaisons' with German women," wrote the playwright Zakhar Agranenko in his diary when serving as an officer of marine infantry in East Prussia. "Nine, ten, twelve men at a time - they rape them on a collective basis."

The Soviet armies advancing into East Prussia in January 1945, in huge, long columns, were an extraordinary mixture of modern and medieval: tank troops in padded black helmets, Cossack cavalrymen on shaggy mounts with loot strapped to the saddle, lend-lease Studebakers and Dodges towing light field guns, and then a second echelon in horse-drawn carts. The variety of character among the soldiers was almost as great as that of their military equipment. There were freebooters who drank and raped quite shamelessly, and there were idealistic, austere communists and members of the intelligentsia appalled by such behaviour.

Beria and Stalin, back in Moscow, knew perfectly well what was going on from a number of detailed reports. One stated that "many Germans declare that all German women in East Prussia who stayed behind were raped by Red Army soldiers". Numerous examples of gang rape were given - "girls under 18 and old women included".

Marshal Rokossovsky issued order No 006 in an attempt to direct "the feelings of hatred at fighting the enemy on the battlefield." It appears to have had little effect. There were also a few arbitrary attempts to exert authority. The commander of one rifle division is said to have "personally shot a lieutenant who was lining up a group of his men before a German woman spreadeagled on the ground". But either officers were involved themselves, or the lack of discipline made it too dangerous to restore order over drunken soldiers armed with submachine guns.

Calls to avenge the Motherland, violated by the Wehrmacht's invasion, had given the idea that almost any cruelty would be allowed. Even many young women soldiers and medical staff in the Red Army did not appear to disapprove. "Our soldiers' behaviour towards Germans, particularly German women, is absolutely correct!" said a 21-year-old from Agranenko's reconnaissance detachment. A number seemed to find it amusing. Several German women recorded how Soviet servicewomen watched and laughed when they were raped. But some women were deeply shaken by what they witnessed in Germany. Natalya Gesse, a close friend of the scientist Andrei Sakharov, had observed the Red Army in action in 1945 as a Soviet war correspondent. "The Russian soldiers were raping every German female from eight to eighty," she recounted later. "It was an army of rapists."

Drink of every variety, including dangerous chemicals seized from laboratories and workshops, was a major factor in the violence. It seems as if Soviet soldiers needed alcoholic courage to attack a woman. But then, all too often, they drank too much and, unable to complete the act, used the bottle instead with appalling effect. A number of victims were mutilated obscenely.

The subject of the Red Army's mass rapes in Germany has been so repressed in Russia that even today veterans refuse to acknowledge what really happened. The handful prepared to speak openly, however, are totally unrepentant. "They all lifted their skirts for us and lay on the bed," said the leader of one tank company. He even went on to boast that "two million of our children were born" in Germany.

The capacity of Soviet officers to convince themselves that most of the victims were either happy with their fate, or at least accepted that it was their turn to suffer after what the Wehrmacht had done in Russia, is striking. "Our fellows were so sex-starved," a Soviet major told a British journalist at the time, "that they often raped old women of sixty, seventy or even eighty - much to these grandmothers' surprise, if not downright delight."

One can only scratch at the surface of the psychological contradictions. When gang-raped women in Königsberg begged their attackers afterwards to put them out of their misery, the Red Army men appear to have felt insulted. "Russian soldiers do not shoot women," they replied. "Only German soldiers do that." The Red Army had managed to convince itself that because it had assumed the moral mission to liberate Europe from fascism it could behave entirely as it liked, both personally and politically.

Domination and humiliation permeated most soldiers' treatment of women in East Prussia. The victims not only bore the brunt of revenge for Wehrmacht crimes, they also represented an atavistic target as old as war itself. Rape is the act of a conqueror, the feminist historian Susan Brownmiller observed, aimed at the "bodies of the defeated enemy's women" to emphasise his victory. Yet after the initial fury of January 1945 dissipated, the sadism became less marked. By the time the Red Army reached Berlin three months later, its soldiers tended to regard German women more as a casual right of conquest. The sense of domination certainly continued, but this was perhaps partly an indirect product of the humiliations which they themselves had suffered at the hands of their commanders and the Soviet authorities as a whole.

A number of other forces or influences were at work. Sexual freedom had been a subject for lively debate within Communist party circles during the 1920s, but during the following decade, Stalin ensured that Soviet society depicted itself as virtually asexual. This had nothing to do with genuine puritanism: it was because love and sex did not fit in with dogma designed to "deindividualise" the individual. Human urges and emotions had to be suppressed. Freud's work was banned, divorce and adultery were matters for strong party disapproval. Criminal sanctions against homosexuality were reintroduced. The new doctrine extended even to the complete suppression of sex education. In graphic art, the clothed outline of a woman's breasts was regarded as dangerously erotic. They had to be disguised under boiler suits. The regime clearly wanted any form of desire to be converted into love for the party and above all for Comrade Stalin.

Most ill-educated Red Army soldiers suffered from sexual ignorance and utterly unenlightened attitudes towards women. So the Soviet state's attempts to suppress the libido of its people created what one Russian writer described as a sort of "barracks eroticism" which was far more primitive and violent than "the most sordid foreign pornography". All this was combined with the dehumanising influence of modern propaganda and the atavistic, warring impulses of men marked by fear and suffering.

The novelist Vasily Grossman, a war correspondent attached to the invading Red Army, soon discovered that rape victims were not just Germans. Polish women also suffered. So did young Russian, Belorussian and Ukrainian women who had been sent back to Germany by the Wehrmacht for slave labour. "Liberated Soviet girls quite often complain that our soldiers rape them," he noted. "One girl said to me in tears: 'He was an old man, older than my father'."

The rape of Soviet women and girls seriously undermines Russian attempts to justify Red Army behaviour on the grounds of revenge for German brutality in the Soviet Union. On March 29 1945 the central committee of the Komsomol (the youth organisation of the Soviet Union) informed Stalin's associate Malenkov of a report from the 1st Ukrainian Front. "On the night of 24 February," General Tsygankov recorded in the first of many examples, "a group of 35 provisional lieutenants on a course and their battalion commander entered the women's dormitory in the village of Grutenberg and raped them."

In Berlin, many women were simply not prepared for the shock of Russian revenge, however much horror propaganda they had heard from Goebbels. Many reassured themselves that, although the danger must be great out in the countryside, mass rapes could hardly take place in the city in front of everybody.

In Dahlem, Soviet officers visited Sister Kunigunde, the mother superior of Haus Dahlem, a maternity clinic and orphanage. The officers and their men behaved impeccably. In fact, the officers even warned Sister Kunigunde about the second-line troops following on behind. Their prediction proved entirely accurate. Nuns, young girls, old women, pregnant women and mothers who had just given birth were all raped without pity.

Yet within a couple of days, a pattern emerged of soldiers flashing torches in the faces of women huddled in the bunkers to choose their victims. This process of selection, as opposed to the indiscriminate violence shown earlier, indicates a definite change. By this stage Soviet soldiers started to treat German women more as sexual spoils of war than as substitutes for the Wehrmacht on which to vent their rage.

Rape has often been defined by writers on the subject as an act of violence which has little to do with sex. But that is a definition from the victim's perspective. To understand the crime, one needs to see things from the perpetrator's point of view, especially in the later stages when unaggravated rape had succeeded the extreme onslaught of January and February.

Many women found themselves forced to "concede" to one soldier in the hope that he would protect them from others. Magda Wieland, a 24-year-old actress, was dragged from a cupboard in her apartment just off the Kurfürstendamm. A very young soldier from central Asia hauled her out. He was so excited at the prospect of a beautiful young blonde that he ejaculated prematurely. By sign language, she offered herself to him as a girlfriend if he would protect her from other Russian soldiers, but he went off to boast to his comrades and another soldier raped her. Ellen Goetz, a Jewish friend of Magda's, was also raped. When other Germans tried to explain to the Russians that she was Jewish and had been persecuted, they received the retort: "Frau ist Frau."

Women soon learned to disappear during the "hunting hours" of the evening. Young daughters were hidden in storage lofts for days on end. Mothers emerged into the street to fetch water only in the early morning when Soviet soldiers were sleeping off the alcohol from the night before. Sometimes the greatest danger came from one mother giving away the hiding place of other girls in a desperate bid to save her own daughter. Older Berliners still remember the screams every night. It was impossible not to hear them because all the windows had been blown in.

Estimates of rape victims from the city's two main hospitals ranged from 95,000 to 130,000. One doctor deduced that out of approximately 100,000 women raped in the city, some 10,000 died as a result, mostly from suicide. The death rate was thought to have been much higher among the 1.4 million estimated victims in East Prussia, Pomerania and Silesia. Altogether at least two million German women are thought to have been raped, and a substantial minority, if not a majority, appear to have suffered multiple rape.

If anyone attempted to defend a woman against a Soviet attacker it was either a father trying to defend a daughter or a young son trying to protect his mother. "The 13-year old Dieter Sahl," neighbours wrote in a letter shortly after the event, "threw himself with flailing fists at a Russian who was raping his mother in front of him. He did not succeed in anything except getting himself shot."

After the second stage of women offering themselves to one soldier to save themselves from others, came the post-battle need to survive starvation. Susan Brownmiller noted "the murky line that divides wartime rape from wartime prostitution". Soon after the surrender in Berlin, Ursula von Kardorff found all sorts of women prostituting themselves for food or the alternative currency of cigarettes. Helke Sander, a German film-maker who researched the subject in great detail, wrote of "the grey area of direct force, blackmail, calculation and real affection".

The fourth stage was a strange form of cohabitation in which Red Army officers settled in with German "occupation wives". The Soviet authorities were appalled and enraged when a number of Red Army officers, intent on staying with their German lovers, deserted when it was time to return to the Motherland.

Even if the feminist definition of rape purely as an act of violence proves to be simplistic, there is no justification for male complacency. If anything, the events of 1945 reveal how thin the veneer of civilisation can be when there is little fear of retribution. It also suggests a much darker side to male sexuality than we might care to admit.

© Antony Beevor.

www.antonybeevor.com

· Berlin: The Downfall 1945 is published by Viking Penguin.The BBC Timewatch film about researching the book will be shown on BBC2 at 9pm on May 10.