In the village of Assola, divided into half by the French-Italian border, the Neapolitan smuggler Giuseppe La Paglia (Totò) and the French customs officer Ferdinand Pastorelli (Fernandel), play a daily cat-and-mouse game, with Ferdinand trying to arrest Giuseppe, and Giuseppe trying to smuggle goods under Ferdinand's nose.
On a celebration day on the town's French side, Ferdinand catches Giuseppe smuggling goods over the border and, after a chase, finally arrests him, consequently arriving late to the traditional parade, where he was supposed to carry the French flag. During the following reception at the Two Borders Hotel, which, as the name suggests, is divided into half by the border, Giuseppe, still under custody, discovers that Ferdinand was born, to an Italian mother and an unknown father, in the very kitchen of the hotel's restaurant. The kitchen is located in the Italian part of the hotel, so Giuseppe argues that Ferdinand is actually Italian and is thus not entitled to act as a French customs officer, making his arrest unlawful. At a subsequent audit with the municipal authorities of Assola, Ferdinand discovers that the man who recorded his birth, Gaspar Donnadiè, owner of the Two Borders, failed to register him in the right place: the Italian municipality. The same Donadiè tells Ferdinand that he went to the French Townhall because it was raining that day and it was a shorter walk than going to the Italian one.
Risking to lose his job, Ferdinand asks for Giuseppe's help, and is taken by him to the Italian side to apply for an Italian identity document, the plan being to subsequently request French naturalisation, thus fixing his position. But, according to a French politician, friend of his father-in-law, having become an Italian citizen will prevent Ferdinand from restoring his French nationality and will also render his marriage invalid and his son illegitimate. As if that was not enough, Ferdinand is placed in custody by the Italian police together with his first wife Antoinette, now married to Giuseppe, because under Italian law, which does not allow for divorce, they are still married and Antoinette is therefore a bigamist. Clarified her marital situation, her first marriage was invalid because of Ferdinand's irregular status, Antoinette is released. On the contrary, Ferdinand is kept because, having served in the war for the French, for the Italians he is a deserter. He is returned to the cell, where now he finds Giuseppe, who has managed to get arrested in order to not leave his wife alone with her ex-husband. Ferdinand, dejected by being called a deserter, attempts suicide, but is persuaded to desist by Giuseppe. He is then released by the police sergeant who, reviewing the case, has discovered that Ferdinand is no longer considered a deserter under the Italian law, but has instead lost all rights to be an Italian citizen.
Being no longer Italian, he is escorted to the border to be sent back to France, but he is blocked there by the head of the local Gendarmerie because he is undocumented and can not enter in the country: Ferdinand has now become both homeless and stateless. Tired of this whole affair he flees to the mountains, armed with the rifle he used as a marksman during the war, to plot his revenge against everyone that wronged him. From the top of a mountain above the village he starts firing "first notice" shots to all his persecutors, carefully listed in his notepad. After this first round of non-lethal warning shots, aimed only at their property, he plans to execute them, one by one. Giuseppe also receives a warning, in the form of a letter: if he does not bring Ferdinand some food, he too will be put on the list of culprits! Giuseppe decides to help Ferdinand and asks for food to Donadiè, who is also on the list and asks Giuseppe to intercede with Ferdinand for him.
When collecting the food, Giuseppe spots on the label of some old wine bottles that the border, now depicted as cutting the hotel in half, used to divide the building in a very different way, with only a small corner actually in Italy. More importantly, according to the map, the kitchen is in fact in France. Confronted, Donadiè confesses that he modified the border to make his hotel more attractive to tourists. Clarified the situation Giuseppe, together with the Italian Police and the French Gendarmerie, rushes to the mountain to convey the news to Ferdinand. He, however, seeing Giuseppe with his enemies, believes that his friend has betrayed him and shoots. Fortunately the bullet hits a bottle of smuggled liquor that Giuseppe was hiding under his clothes and does not injure him. Ferdinand, believing to have killed his friend, abandons his sniper nest to rush to his side and is finally informed of the truth: he was born in France and can return to his old life.
The film ends as it started, with Ferdinand once again chasing Giuseppe, only stopping to address the audience to recognize that, even if he knows he owes him gratitude, he cannot simply let Giuseppe go scot free, because, in the end, "the Law is the Law!"