BT has ended the uncertainty over television coverage of Scottish football by announcing a deal which secures top-flight and lower division football for armchair fans over the next four seasons.

The communications giant said it was taking over ESPN's channels in the UK and Ireland in a buyout which will allow it to show 30 games from the Scottish Premier League (SPL) a year plus 10 Rangers games.

Fans had been left unsure over ESPN's involvement in Scottish football beyond this season after it emerged the company had a get-out clause in its SPL contract which meant it could have walked away from the game in the summer.

ESPN signed a joint £80 million deal along with Sky TV for the rights to Scottish football last year, with ESPN's contribution thought to be around £4m a season.

However, the broadcaster suffered a change of heart and is understood to have been keen to get out of football after losing the rights to show matches from the English Premier League.

BT, which has diversified away from its traditional model as a phone landline provider over the past decade, has committed to broadcast games until at least 2017.

SPL chief executive Neil Doncaster welcomed the deal and said it would have hugely a beneficial economic impact on Scottish football.

He said: "We look forward to working closely with BT from the beginning of next season. Today's announcement is positive for the Scottish game.

"It means top-flight football will continue to be broadcast by Sky Sports and now BT, providing a solid financial bedrock and the best possible platform to promote the game in Scotland."

The transaction is expected to go through on July 31, after which BT will continue to operate at least one ESPN-branded channel which is expected to form part of the BT Sport TV package, due to be launched this summer.

BT Retail's Marc Watson said: "We're really thrilled to be involved with Scottish Premier League football. We're looking forward to bringing some of the very best action to fans."

As well as the Clydesdale Bank Scottish Premier League, the deal will enable BT Sport customers to see live coverage of the FA Cup for the 2013/14 season, the UEFA Europa League and German Bundesliga through to the end of the 2014/15 season.

The company has already secured deals to show live Barclays Premier League and Aviva Premiership Rugby matches for the next four seasons.

The ESPN channels currently televise a host of US sports currently shown on ESPN America, including NCAA College Basketball, NCAA College Football and NASCAR.

BT's channels will be broadcast from the Queen Elizabeth Olympic Park in Stratford.

Mr Watson added: "We are delighted to have reached agreement with ESPN for the acquisition of their UK channels business and we have been able to add some exciting new sports rights to the ones we already have."

Ross Hair, managing director, ESPN – Europe, Middle East and Africa, said: "We could not be more proud of the television channels built and nurtured by our talented team over the past four years.

"The value of that hard work is reflected in this deal with BT and the continuation of ESPN on television screens across the UK and Ireland."

It is unclear who will present Scottish coverage, but BT has already signed up Jake Humphrey, the former BBC Formula One anchor, to front its English Premiership programmes on a reputed annual salary of more than £250,000.