NATO took a historic step today toward making Spain its 16th member, an act intended to fill a strategic gap on the southwestern flank of the alliance in Europe and to strengthen democracy in post-Franco Spain.

In what NATO Secretary General Joseph Luns called "one of the most significant events in the life" of the alliance, Secretary of State Alexander M. Haig Jr. and representatives of the other 14 NATO allies signed a formal invitation to Spain. After this protocol of accession has been ratified by all member governments and then is formally accepted by the Spanish government, Spain will become the first new NATO member since West Germany joined in 1955.

Spanish Foreign Minister Jose Pedro Perez-Llorca said it was another major step for Spain, on the third anniversary of its new democratic constitution, away from the decades of Franco dictatorship when it "was kept apart from the political and defense institutions of the European and Atlantic community, whose values, culture and way of life Spain helped to shape in a decisive way."

Spain would add 340,000 troops, more than 190 American- and French-made war planes, eight submarines and 29 warships to the alliance military command. Located strategically along both Atlantic and Mediterranean coasts at the entrance to the Mediterranean, Spain is expected to play an important role in NATO's air and anti-submarine defenses.

The news media were given rare access to the main conference hall of NATO headquarters here to record this ceremonial show of Western unity, which masked a number of internal disagreements and concerns at this week's semiannual meetings of NATO defense and foreign ministers.

While U.S. officials said a briefing by chief negotiator Paul Nitze on the nuclear arms control talks with the Soviet Union in Geneva was "very well received," the growing nuclear disarmament movement in Europe reportedly was an important subject of discussion in a later session today.

Earlier this week, the European defense ministers rejected a U.S. request to double alliance spending next year for construction of base facilities and other NATO infrastructure. European resistance to a Reagan administration request for strong support in its accelerating confrontation with Libya also surfaced, and a disruptive public political rift developed between Greece and Turkey.

Greek Prime Minister Andreas Papandreou returned to Athens after blocking publication here yesterday of the formal communique of the NATO defense ministers because it did not satisfy his demand for a pledge by alliance members to protect Greece from attack by Turkey.

Today, Turkish Defense Minister Umit Haluk Bayulken said "a Turkish threat to Greece is an absurd and preposterous proposition" despite longstanding differences between the two countries, including competing claims to the island of Cyprus, which Turkish troops invaded in 1974. Greece withdrew from the NATO military command to protest the invasion and returned only last year under an agreement negotiated by NATO's supreme commander, Gen. Bernard Rogers.

Bayulken said today that Papandreou did not make clear whether his new Socialist government in Greece was now seeking to abrogate or renegotiate that agreement. Under it, Greece and Turkey were to work out a way to share military flight control of the air space over the Aegean Sea, for which Greece had sole responsibility before 1974.Bayulken said this was "the heart of the question" raised by Papandreou.

While he said he hoped the problem could be solved by discussions, Bayulken told reporters, "it would be a big problem, a very serious situation" if Greece ultimately rejected the Rogers agreement.

Papandreou's government also had recently threatened that Greece would not sign the invitation for Spain to join NATO. But Greece did in the end join in signing along with the other alliance members.

Spanish Foreign Minister Perez-Llorca said he also did not expect Spanish Socialist opposition to NATO membership to overturn recent parliamentary approval of the government's decision. But NATO diplomats acknowledged here that their governments will try to win ratification of the invitation before the Spanish parliamentary election next spring.

Spain has been linked to the NATO defense structure for the past five years through a treaty with the United States allowing its forces to use two air bases and one naval base there. About 10,000 U.S. Navy and Air Force personnel and an equal number of dependents are currently stationed in Spain. The treaty, which had been extended six months for renegotiation after expiring in September, would no longer be necessary after Spanish entry into NATO, Perez-Llorca said today.

He also said NATO membership would make it easier for Spain and Britain to resolve their dispute over Gibraltar, which the British rule and the Spanish claim.