Expanded from an earlier answer of mine
Wojciech Jaruzelski's declaration of martial law on 13 December 1981- seen in part here- is one of the more controversial episodes in Polish history. Jaruzelski throughout his speech maintained that martial law was a necessary evil and he would continue this line throughout the 1980s and 90s. The fall of communism also led Jaruzelski to be more assertive about his fears of Soviet intervention, particularly the Soyuz-81 exercise in which the Soviet and Warsaw Pact forces held maneuvers at the Polish borders in March 1981 and many of these forces remained at the border after the exercise's conclusion. Nonetheless, the archival evidence backing up Jaruzelski's claim are rather mixed.
The Soviet Politburo's official record for 10 December shows that it rebuffed Jaruzelski's request for Warsaw Pact support. This not only undercuts the narrative of using martial law to forestall invasion, but also the Polish general's post-1989 claim that he was acting as a patriotic Pole who would never invite foreign help. Conversely, the Soviet's Suslov Commission's report from the summer indicated that "counterrevolutionary" Solidarity movement posed an existential threat to the rule of the PZPR. Documentary evidence from both the GDR and Czechoslovakian archives has also shown there were some rather well-developed plans for a Pact invasion of Poland. So while the Politburo may have rebuffed Jaruzelski's request for aid in December 1981, they sent quite different signals earlier in the year and it was also fairly clear that if Jaruzelski failed to rein in Solidarity the Soviets might invade. Additionally, there was also significant pressure from Poland's Pact neighbors for Poland to take care of its own problems. The hardliner GDR General Secretary Erich Honecker was afraid that Solidarity's mass disturbances could spill over into the GDR and while many in the Kremlin were reluctant to invade Poland, their allies in their satellite states could force Moscow's hand. On a deeper level, the Polish crisis, as well as Afghanistan, imparted to the upcoming (and last) generation of Soviet leaders the lesson that military intervention was easier to plan than carry through and had the potential to open up a Pandora's box of unintended consequences.
These were the unenviable contingencies that faced Jaruzelski in December 1981 and there is some veracity to his claim that martial law was the least worst option for him. The Soviets had enough military force to invade the country, but just barely. Thealready possessed the Northern Group of Forces in Poland which consisted of two divisions. As the Solidarity strikes heated up and the Kania government appeared to be vacillating, the Suslov Commission which recommended an increased mobilization and massing of Red Army forces on the Soviet-Polish border consisting of three tank divisions and one mechanized rifle division. The Suslov Commission also produced a memo which stressed that if Polish "counterrevolutionary" resistance escalated, the Soviets would need to mobilize another five to seven divisions. The Soviets also had the assistance of both the GDR and Czechoslovakia, whose hardline leaders feared that Solidarity would infect their own populations.
However, an invasion of Poland was a risky proposition even with the assistance of the East German and Czechoslovakian satellite states. Soviet plans called for the Polish armed forces to assist the invasion, or at least stay in their barracks. The force structure had only the minimal number of troops needed to handle an invasion had the Polish Army resisted the invasion.The CIA and State Department publicized a faulty intelligence report that claimed that the Soviets had fifteen, not four, divisions on the Polish border. This report as well as the Reagan White House's staunch anticommunist line gave further ammunition to Jaruzelski's defense of his actions claiming that a Soviet invasion could have precipitated a superpower conflict.
It is very difficult to tell in hindsight if Moscow was willing to follow through with its military plans or if its mobilization was an attempt to strong arm the Polish government into action. Both the intervention against Prague Spring and the recent invasion of Afghanistan left a bad taste in the Soviet's mouth for military solutions to political problems. Both invasions were publicity disasters and Afghanistan was already shaping up to be a quagmire in 1980. However, the aging Brezhnev clique was unwilling to brook any attempt to undercut Soviet power in what it saw as its sphere of influence. The US's intelligence reports gave the Polish government an way out of its domestic impasse since there was little stomach throughout the alliance for fighting what would have turned out to be a fratricidal war among the Warsaw Pact. Nor was there much for the US to do to prevent Soviet military intervention. Polish martial law was for all the geopolitical players the least worst alternative; it eased Soviet concerns and allowed a further renegotiation of its relationship to Poland while the Americans got to score ideological points against the USSR without having to seem impotent. Poland's communist leaders got to forestall making hard political decisions about their domestic unpopularity, which was the comfortable normal for the Warsaw Pact leadership for most of the Cold War.
Whether or not the Polish Army would have participated within a Warsaw Pact invasion in 1981 or resisted it is an unknown hypothetical, but the narratives surrounding Poles' rejection of communism does have resonance in the post-Cold War world. Speaking broadly to evade discussions that broach the 20-year rule, there is a strain of post-Cold War Polish nationalism that contends that communism was a political prison wholly imposed on Poland from the outside. Thus the Polish nation is not guilty of being communist outside of a few unsavory types. This is why the idea of Żydokomuna (Jew communism) is so common online and elsewhere as it presents a convenient other- Jews- which to pin the crimes of communism. That there were Polish communists who conceived of themselves as Poles and did not see their embrace of communism as counter to their sense of Polishness runs against this narrative of Polish national victimization. And the Polish nationalism of its communist leadership did cause frictions between Poland and the other Pact states. The GDR was never able to get much traction from Warsaw over issues like revising the Oder-Neisse on terms of socialist brotherhood because of memories of German subjugation of Poland. Jaruzelski's narrative as it evolved after the fall of communism took on shades casting him as a patriotic Pole who wanted to reform communism like Gorbachev and this is not entirely an ex post facto rationalization of his actions. The martial law crackdown did not follow earlier patterns in other Pact states wherein the state tacked to a more politically-hardline course after repressing political movements. The suppression of Solidarity was not especially thorough and there is some evidence that Jaruzelski and company sought to remove those who it saw as the ideologues from the movement. Martial law also witnessed an attempt to both liberalize the economy and clear out the deadwood in the PZPR.
Yet such a generous interpretation of Jaruzelski can go too far and he had every interest in the post-1989 period to portray his actions in the best and most patriotic light. There were attempts to bring him up on charges for martial law as well as other crimes, but these trials became mired in legalistic muck. Jaruzelski and his defenders did their best to muddy the waters as to his motivations in 1981, as did his many critics who accused him of reaching of trying to erect a military dictatorship. As for the issue of a potential Soviet invasion, the evidence is unclear and contradictory. The Soviets did have a vested interest in peace in Poland and had the minimum amount of force to invade the country. Yet it is also clear that the Kremlin did not relish the prospect of an invasion. This makes it hard to determine if actions like Soyuz-81 were genuine threats or just sabre-rattling.
Sources
Kemp-Welch, Anthony. Poland Under Communism: A Cold War History. Cambridge: Cambridge University Press, 2016.
MacEachin, Douglas J. U.S. Intelligence and the Confrontation in Poland, 1980-1981. University Park, PA: Pennsylvania State University Press, 2002.
Mastny, Vojtech. "The Soviet Non-Invasion of Poland in 1980-1981 and the End of the Cold War." Europe-Asia Studies 51, no. 2 (1999): 189-211.
Ouimet, Matthew J. "National Interest and the Question of Soviet Intervention in Poland, 1980-1981: Interpreting the Collapse of the'Brezhnev Doctrine." The Slavonic and East European Review (2000): 710-734.
_.The Rise and Fall of the Brezhnev Doctrine in Soviet Foreign Policy. Chapel Hill, NC: The University of North Carolina Press, 2003.
Paczkowski, Andrzej. Revolution and Counterrevolution in Poland, 1980-1989: Solidarity, Martial Law, and the End of Communism in Europe. University of Rochester Press, 2015.