Green’s Dictionary of Slang

fig (of Spain) n.

also figo

a coarse gesture of dismissal whereby one sticks one’s thumb up between two forefingers .

[UK]U. Fulwell Art of Flattery 2nd dial. 8: For a token I thee sende / A dotinge Fig of Spayne.
[UK]Shakespeare Henry V III vi: Die and be damn’d; and figo for thy friendship! [...] The fig of Spain!
[UK]R. Davenport A New Tricke to Cheat the Divell I ii: If none be gall’d, you have no cause to wince, But if you be, then Figo.
[UK]Navy at Home II 117: Then says you ‘fie! fie!’ who, fie?— a fico for your fie, ‘the fig of Spain’.

In phrases

give the fig (v.)

to stick one’s thumb up between two forefingers as a gesture of derision.

[UK]R. Nares Gloss. (1888) I 305: fig, to give the. An expression of contempt or insult, which consisted in thrusting the thumb between two of the closed fingers, or into the mouth, whence Bite the thumb. The custom is generally regarded as being originally Spanish. According to some authors, it conveyed an insulting allusion to a contemptuous punishment inflicted on the Milanese, by the emperor Frederic Barbarossa, in 1162, when he took their city [...] But this has much the air of a fable.