SYDNEY (AP) Australia booked its place in next year's World Baseball Classic by beating South Africa 12-5 in Sunday's final of a qualifying tournament, securing victory with a six-run eighth inning that was helped by a two-run throwing error on a bunt.

In a game where the lead changed hands four times, Mitch Dening and Trent Oeltjen hit run-scoring singles in the bottom of the seventh inning to break a 4-4 tie and give Australia a decisive 6-4 lead.

''I knew from the start that this wasn't going to be an easy competition,'' Australian manager Jon Deeble said on the MLB website.

More from FoxSports

''People said it would be a walk in the park, and I said, `This is going to be tough.' They proved that. 12-5, they sort of lacked a bit of depth in their bullpen, but a couple more arms in the bullpen and it might be a one-run game.''

South Africa shortstop Gift Ngoepe led off the game with a long homer to left field off Australian starter Travis Blackley. But the Australians tied it in the bottom of the first on Oeltjen's RBI double off South Africa starter Kyle Gaddin.

Australia's second baseman Brad Harman and catcher Allan de San Miguel hit consecutive solo home runs in bottom of fifth, both off South Africa reliever Carl Michaels, to give Australia a 3-1 lead.

Catcher Kyle Botha's three-run homer in the top of sixth off Blackley put South Africa up 4-3 but Australia, which outhit South Africa 17-7, tied it in the sixth on Trent D'Antonio's run-scoring double, before Dening and Oeltjen made it 6-4.

South Africa scored a run off Australian Baseball League save leader Ryan Searle in the top of the eighth to close to within 6-5, before Australia's six unearned runs in the bottom of the inning.

Former Atlanta Braves pitcher Peter Moylan (1-0) threw 1 1-3 scoreless innings for the win and Searle picked up his second save of the tournament.

''The pitching started to get tired, and then once we got beyond the guys we were comfortable with, we had to go to some rookies who have not been exposed to this level of baseball,'' said South Africa manager Alan Phillips. ''It is difficult to play this level if you are not exposed ... on a regular basis.''

Every Australian starter had at least one hit. Oeltjen, who came out of retirement to play, finished 3-for-4 with two doubles and two RBIs. Dening had two hits and two steals and D'Antonio added three RBIs.

The WBC qualifying tournament also included the Philippines and New Zealand. South Africa beat New Zealand 9-2 in a semifinal Saturday, while the Philippines lost both games.

The Sydney tournament was the first of four WBC qualifiers. Others will be held from March 17-20 in Mexicali, Mexico (featuring Czech Republic, Germany, Mexico and Nicaragua), and Panama City, Panama (Colombia, France, Panama and Spain); and from Sept. 22-25 in Brooklyn, New York (Brazil, Britain, Israel and Pakistan).

Australia and the other three qualifiers will join Canada, China, Cuba, defending champion Dominican Republic, Italy, Japan, the Netherlands, Puerto Rico, South Korea, Taiwan, the United States and Venezuela in next year's tournament. It is expected to be held in March 2017 although a host country or countries have not been announced.