The best view of Spain from Gibraltar is down the barrel of a gun.

The 1,400-foot-high limestone Rock that towers over Spain was first tunneled through in the 18th century and air vents were opened up on the north face that were immediately found to be excellent embrasures for installing cannon batteries. It was an artillery man's dream, and the British were able to rain down shot and shell on the oncoming Spaniards.

Resisting Spain has been the constant reference point in Gibraltar's history as a British Crown Colony. Spain was claiming the return of the 2.5-square-mile Rock from the moment it had been forced to cede it, supposedly in perpetuity, in the 1713 Treaty of Utrecht. The last of Spain's sieges formally ended Tuesday when Madrid ended all border restrictions, and it is little wonder that Gibraltarians, isolated for most of the past 20 years, are wondering what happens next.

Juan Manuel Triay is a wealthy Gibraltarian lawyer whose yacht was once set ablaze by irate fellow residents for proposing the idea of direct negotiations with Spain. Triay is fairly certain what will happen next: "Tf Spain is clever and efficient at the game there is a strong possibility that she will absorb Gibraltar economically and politically and Gibraltar's identity as well."

Along with the border reopening, the foreign ministers of Spain and Britain met in Geneva, set up a series of working committees to discuss differences over Gibraltar and agreed to meet again at the end of the year to review progress. Spain reopened the border because Britain for the first time agreed to have the issue of sovereignty on the agenda.

British Prime Minister Margaret Thatcher sought to reassure Gibraltarians when she told London's House of Commons: "Her Majesty's government will never enter into arrangements under which the people of Gibraltar will pass under the sovereignty of another state against their freely and democratically expressed wishes."

But Rock residents were reassured only up to a point. With sovereignty on the agenda and the border reopened, one Gibraltarian businessman pointedly asked: "Haven't we let in the Trojan horse?"

THE BEST HOTEL in Gibraltar serves a real English breakfast with bacon and sausages imported from Britain (the eggs are obtained in Morocco) and serves a proper English tea between 4 and 6 p.m. on a terrace that overlooks the Bay of Algeciras. The full-length curtains in the hotel dining room, however, have been taken up again and again to the point where they stand a foot off the floor. It is an example of a run-down in capital investment over the past 20 years of border restrictions and siege conditions.

While Gibraltar stood still and began to fray at the edges, Spain boomed. Now the port of Algeciras, across the bay, controls the ferry service to Tangiers and the commerce with Morocco.

Industry has sprung up along the bay area where a petrochemical complex twinkles away at night. Spain's Mediterranean coast, stretching northward from Gibraltar, has become a major holiday playground.

Joseph Gaggero, the president of a Gibraltarian corporation that has shipping, aviation, hotel and holiday tour interests, concedes that "for the past 20 years the whole focus of our economy has been resisting the restrictions." He fears a future in which Gibraltar could be reduced to dependence on day trippers and Gibraltarians would be parking lot attendants and tour guides.

But John Crosson, a U.S. financier who divides his year between New York and the Spanish resort of Sotogrande, just 20 minutes from Gibraltar, has a second future scenario, involving offshore banking.

Gibraltar has generous legislation on company tax exemptions, a favorable time zone, English as the spoken language and an English system of common law as well as a ready-made infrastructure of lawyers and accountants. Crosson talks of "at least" 100,000 well-to-do expatriates, mostly U.S. and British, living on the Spanish coast. "Wouldn't they rather drive to Gibraltar to do their banking and trust business instead of flying to Zurich?" he asks.

It is another question whether European Community regulations, particularly if Spain joins on schedule next year, will allow Gibraltar to become a European Cayman Islands for tax dodgers. Any buildup of The Rock as an offshore investment center would necesarily have to involve the sanction of Madrid, thereby underlining the potential economic dependence of The Rock on the Spanish mainland.

THE BEST PAGEANTRY in Gibraltar compares with that outside Buckingham Palace in London. The garrison in residence on The Rock is the first battalion of The Queen's Regiment, which arrived for a two-year tour of duty at the end of January after 28 months in Northern Ireland. Every Tuesday morning they carry out an elaborate changing of the guard outside the residence of Gibraltar's governor.

Gibraltar's 209-strong police force may wear the blue uniform of the British Bobby and the lawyers and judges in The Rock's court building wear wigs. There are English shops selling English goods and British pubs offering British bitter beer. Gibraltar became a colony because it had strategic value and the whole Britishness of the rock is the result of the continuing military presence. Yet, aside from the wealthy who give dinner parties for the colonel of the regiment and his officers, the 25,000-odd Gibraltarian civilians live back to back with the 5,000-odd military personnel and their dependents.

Joe Bossano is the leader of Gibraltar's Social Democratic and Labor Party, which controls seven of the 15 seats in Gibraltar's legislature. He is a graduate of the London School of Economics. "I am neither British nor Spanish,+ says Bossano. "I am Gibraltarian." Bossano is president of The Rock's 7,000-strong union members and he is tipped to wrest power in the Gibraltar assembly from the veteran conservative chief minister, Joshua Hassan.

Bossano, who is more eloquent in Spanish than in English, said: "Ultimately the only way that Gibraltar can go is toward self-government." He admitted that foreign affairs and defense will always be in the hands of a bigger state: "If we were to put Gibraltarian ambassadors around the world there would be nobody left on The Rock."

Solomon Levi is a Gibraltar real estate agent, a cousin of the chief minister, who never misses a Tuesday parade if he can help it and who sells property in Spain to Gibraltarians who wish to escape The Rock's cramped conditions and high rents. "Bossano and his people, given a few years, will be picking up the jobs and the perks that the Spanish Socialist government offers them," he said.

THE BEST JOKE heard on The Rock this week was cracked by an onlooker at the parade in front of the governor's residence. The regimental band was negotiating its way down Gibraltar's main thoroughfare to the tune of "Bond of Friendship." "That's for the Spaniards," said the onlooker. Then, as the guard changed, the band struck up the theme tune of the movie "Shaft." "That's for the Gibraltarians," said the wit, an Englishman.

Spanish officials are confident that Britain's negotiators have taken careful note of a broad set of Madrid proposals that focus on transition periods for the return of sovereignty to Spain.

Spain is offering a lease-back formula or a condominium in which power would be shared jointly by Madrid and London during an interim period. Spain, which has already granted wide-ranging self-government powers to Spanish regions, is also willing to enact a specific autonomy statute, tailor-made for Gibraltar, that will ensure Gibraltarian citizenship for Rock residents and the continuation of their own judicial, legislative and executive institutions.

The issue of the British base on Gibraltar remains. According to Spanish officials, should the sovereignty issue be resolved through transition measures, there is no objection in principle to a continued British base, albeit with an honorary Spanish commander. This would be on similar lines to the U.S. bases presently in Spain. The bases are in practice fully controlled by the United States but are technically Spanish bases jointly used by Spain and the Americans.

Legend has it that Gibraltar will be British as long as there are Barbary apes on The Rock. Winston Churchill ensured at the height of World War II that the apes continued scampering up and down the escarpments, and the monkey colony now numbers 53. But it might be a different matter when the apes are living their amiable life thanks to mostly Spanish tourists feeding them peanuts.