In the UK, broadly speaking it is not illegal to pay a ransom.
However, there may be circumstances such that arranging or paying a ransom constitutes a terrorist financing offence - although a prosecution might be deemed against the public interest. I'm not aware of any such prosecutions.
Section 15 (3) of the Terrorism Act 2000 makes it an offence for a person to provide money or other property if he knows or has reasonable cause to suspect will or may be used for the purposes of terrorism.
Section 17 makes it an offence for a person to enter into or become concerned in an arrangement as a result of which money or other property is made available or is to be made available to another, and the person knows or has reasonable cause to suspect that it will or may be used for the purposes of terrorism.
Section 17A makes it an offence for an insurer to make a payment under an insurance contract against kidnapping and ransom if he knows or has reasonable cause to suspect that the money or other property has been, or is to be, handed over in response to a terrorist demand.
Section 18 makes it an offence for someone to enter into or become concerned in an in an arrangement which facilitates the retention or control by or on behalf of another person of terrorist property.
If a person becomes aware in the course of his trade, profession or business (e.g. the banker assembling the money) that someone may be arranging a ransom to pay a terrorist, section 19 makes it an offence for that person to not disclose to a constable as soon as reasonably practicable his belief or suspicion and the information on which it is based.
In terms of maritime piracy kidnappings in the area of Somalia for example, although the Government has tried to link them to terrorism there is no direct evidence of systematic links. But if it became known that such a connection exists, then the knowledge or suspicion element of the terrorist financing offences might be provable.
In Masefield AG v Amlin Corporate Member [2011] EWCA Civ 24 (a case partly about whether ransom payments by shipowners to pirates were as a matter of English law against public policy) the Court of Appeal was not aware of illegality in the payment of ransoms under international law.
The UK Government supported the adoption of UN Security Council Resolution 2133 in January 2014, which among other things "Calls upon all Member States to prevent terrorists from benefiting directly or indirectly from ransom payments or from political concessions and to secure the safe release of hostages".