The wrangle started in September 2009 when ITV launched proceedings to recover a gross debt of £38m, which it said was a net debt between £15m and £20m, as a result of STV "not honouring its contractual contributions towards the network programming budget".
STV filed a countersuit two months later seeking £47m in damages from ITV including £12m for exploiting new media rights without its consent and £35m "in respect of the airtime sales agreement by ITV Consumer".
The case was due in court next month.
STV contributes a percentage towards the ITV network programming budget. It is understood STV had opted out of a number of peaktime dramas, including the popular series 'Downton Abbey', without giving the notice ITV was entitled to.
In a joint statement issued today the two sides said they had agreed "the basis of a much more collaborative relationship for the future which will avoid a recurrence of the issues which resulted in legal action".
When asked whether STV had gained anything in regards to new media rights, a spokesman declined to give a clear answer. He said: "It's too early to say how it will translate into hard numbers."
STV was keen to stress the cash impact of the £18m settlement was only £4.8m.
The terms consist of £7.2m in cash payable this year, offset by £2.4m of credit for programme opt-outs in 2011.
The other £10.8m will be payable either in programme rights as at 31 December, or cash, as adjusted, depending on further discussions with ITV.
STV expects to book, in addition to its current provisions, an exceptional charge as a result of this settlement of £9m in its financial results for the first half of 2011.
Both two sides will also have incurred legal costs in pursuing their claims.