The NBA Finals was on pace to hit a four-year low in ratings and viewership, but a sixth and seventh game lifted the numbers to a three-year high.

The seven-game Heat/Spurs NBA Finals averaged a 10.5 final rating and 17.7 million viewers on ABC, up 4% in ratings and 5% in viewership from last year’s five-game Heat/Thunder series (10.1, 16.9M), and up 3% and 2%, respectively, from the six-game Mavericks/Heat series in 2011 (10.2, 17.3M).

ESPN Deportes, which aired the NBA Finals for the first time this year, averaged 142,000 viewers for the series — bringing the seven-game total across the two networks to 17.8 million.

Through five games, Heat/Spurs was the lowest rated and least-viewed NBA Finals since Lakers/Magic in 2009, averaging a (still respectable) 9.1 rating and 15.1 million viewers. Aided by Games 6 and 7, the series finished as the highest rated and most-viewed since Lakers/Celtics in 2010 (10.6, 18.1M).

Overall, the series ranks as the third-highest rated and third-most viewed NBA Finals on ABC since the network resumed airing games in the 2002-03 season, trailing only Lakers/Celtics in ’10 and Pistons/Lakers in 2004 (11.5, 17.9M).

Heat/Spurs also ranks as the most-viewed NBA Finals to ever involve the Spurs, topping the previous high of 16.0M for Spurs/Knicks in 1999. The 1999 series still averaged a higher rating (11.3). The Spurs’ three other appearances in the NBA Finals each averaged less than an 8.5 rating and 13 million viewers.

The past four NBA Finals have now averaged a double-digit rating and at least 16 million viewers. By comparison, six of the previous seven series averaged a single-digit rating and under 15 million.

As mentioned before, Spurs/Heat was helped by strong performances for Games 6 and 7. Game 6 ranks as the seventh-most viewed NBA game of any kind since 1998, and Game 7 ranks as the second-most viewed. Both games earned over 20 million viewers, marking the first time since 2004 that multiple games in an NBA playoff series topped the 20 million mark.

Compared to other sports, the NBA Finals trailed the three-game NCAA Tournament Final Four (11.0, 18.3M*), but finished comfortably ahead of the five-game Bowl Championship Series (8.8, 15.1M). The NBA Finals also easily outdrew last year’s World Series (7.6, 12.7M).

Among adults 18-49, the NBA Finals averaged a 7.1 rating — matching both last year and 2011 as the third-best for the NBA Finals since ABC acquired the rights. Only 2004 (7.9) and 2010 (7.3) did better. The series also averaged a 7.2 among adults 18-34 and a 7.4 among adults 25-54.

* CBS Final Four averages unofficial.

Averages For the NBA Finals, past decade

(Series averages from ESPN Media Zone 1, 2; additional info from ABC)