The Treaty of Utrecht
Article X
On the 13th July 1713, at the end of the War of the Spanish Succession (1704-1713), a peace treaty was signed by the warring nations at Utrecht in the Netherlands (Holland). In Article X of the Treaty, Spain surrendered Gibraltar to Britain.
Article X of the Treaty in English AAA Article X of the Treaty in Spanish
 
The Arms of Queen Anne of Great Britain A The Arms of King Philip V of Spain
A A A
The Catholic King does hereby, for himself, his heirs and successors, yield to the Crown of Great Britain the full and entire propriety of the town and castle of Gibraltar, together with the port, fortifications, and forts thereunto  belonging; and he gives up the said propriety to be held and enjoyed absolutely with all manner of right for ever, without any exception or impediment whatsoever. El Rey Católico, por sí y por sus herederos y sucesores, cede por este Tratado a la Corona de la Gran Bretaña la plena y entera propiedad de la ciudad y castillos de Gibraltar, juntamente con su puerto, defensas y fortalezas que le pertenecen, dando la dicha propiedad absolutamente para que la tenga y goce con entero derecho y para siempre, sin excepción ni impedimento alguno.
But that abuses and frauds may be avoided by importing any kind of goods, the Catholic King wills, and takes it to be understood, that the above-named  propriety be yielded to Great Britain without any territorial jurisdiction and without any open communication by land with the country round about. Pero, para evitar cualquiera abusos y fraudes en la introducción de las mercaderías, quiere el Rey Católico, y supone que así se ha de entender, que la dicha propiedad se ceda a la Gran Bretaña sin jurisdicción alguna territorial y sin comunicación alguna abierta con el país circunvecino por parte de tierra.
Yet whereas the communication by sea with the coast of Spain may not at all  times be safe or open, and thereby it may happen that the garrison and other inhabitants of Gibraltar may be brought to great straits; and as it is the  intention of the Catholic King, only that fraudulent importations of goods  should, as is above said, be hindered by an inland communications, it is therefore provided that in such cases it may be lawful to purchase, for ready  money, in the neighbouring territories of Spain, provisions and other things  necessary for the use of the garrison, the inhabitants, and the ships which lie in the harbour. Y como la comunicación por mar con la costa de España no puede estar abierta y segura en todos los tiempos, y de aquí puede resultar que los soldados de la guarnición de Gibraltar y los vecinos de aquella ciudad se ven reducidos a grandes angustias, siendo la mente del Rey Católico sólo impedir, como queda dicho más arriba, la introducción fraudulenta de mercaderías por la vía de tierra, se ha acordado que en estos casos se pueda comprar a dinero de contado en tierra de España circunvencina la provisión y demás cosas necesarias para el uso de las tropas del presidio, de los vecinos u delas naves surtas en el puerto.
But if any goods be found imported by Gibraltar, either by way of barter for  purchasing provisions, or under any other pretence, the same shall be confiscated, and complaint being made thereof, those persons who have acted  contrary to the faith of this treaty, shall be severely punished. Pero si se aprehendieran algunas mercaderías introducidas por Gibraltar, ya para permuta de víveres o ya para otro fin, se adjudicarán al fisco y presentada queja de esta contravención del presente Tratado serán castigados severamente los culpados.
And Her Britannic Majesty, at the request of the Catholic King, does consent and agree, that no leave shall be given under any pretence whatsoever, either to Jews or Moors, to reside or have their dwellings in the said town of Gibraltar; and that no refuge or shelter shall be allowed to any Moorish ships  of war in the harbour of the said town, whereby the communication between Spain and Ceuta may be obstructed, or the coasts of Spain be infested by the excursions of the Moors. Y su Majestad Británica, a instancia del Rey Católico consiente y conviene en que no se permita por motivo alguno que judíos ni moros habiten ni tengan domicilio en la dicha ciudad de Gibraltar, ni se dé entrada ni acogida a las naves de guerra moras en el puerto de aquella Ciudad, con lo que se puede cortar la comunicación de España a Ceuta, o ser infestadas las costas españolas por el corso de los moros.
But whereas treaties of friendship and a liberty and intercourse of commerce are between the British and certain territories situated on the coast of Africa, it is always to be understood, that the British subjects cannot refuse the Moors and their ships entry into the port of Gibraltar purely upon the account of  merchandising. Y como hay tratados de amistad, libertad y frecuencia de comericio entre los ingleses y algunas regiones de la costa deAfrica, ha de entenderse siempre que no se puede negar la entrada en el puerto de Gibraltar a los moros y sus naves que sólo vienen a comerciar.
Her Majesty the Queen of Great Britain does further promise, that the free exercise of their religion shall be indulged to the Roman Catholic inhabitants of the aforesaid town. Promete también Su Majestad la Reina de Gran Bretaña que a los habitadores de la dicha Ciudad de Gibraltar se les concederá el uso libre de la Religión Católica Romana.
And in case it shall hereafter seem meet to the Crown of Great Britain to grant, sell or by any means to alienate therefrom the propriety of the said town of  Gibraltar, it is hereby agreed and concluded that the preference of having the sale shall always be given to the Crown of Spain before any others. Si en algún tiempo a la Corona de la Gran Bretaña le pareciere conveniente dar, vender, enajenar de cualquier modo la propiedad de la dicha Ciudad de Gibraltar, se ha convenido y concordado por este Tratado que se dará a la Corona de España la primera acción antes que a otros para redimirla.
The Arms of Utrecht