Rory McIlroy had to produce some late heroics to reach the last 16 of the WGC-Cadillac Championship in San Francisco, while Lee Westwood claimed the notable scalp of Masters champion Jordan Spieth.

McIlroy, Spieth, Westwood,  and Billy Horschel had all won their first two group matches at Harding Park, meaning Friday's contests would decide which players advanced to the knockout stages.

And after Westwood recovered from losing the first two holes to beat Spieth on the 18th, McIlroy came from two down after 16 to beat Horschel on the 20th hole.

McIlroy holed from 25 feet for birdie on the 17th to keep the match alive and also birdied the 18th as FedEx Cup winner Horschel failed to get up and down from the side of the green.

Both players then missed from 12 feet for birdie on the first extra hole before McIlroy saved par from a greenside bunker on the next and Horschel was again unable to get up and down from off the green.

In reference to his putt on 17th, he told reporters: "I drew on the Ryder Cup at Gleneagles to a putt I hit with Sergio. Both were 'Make it or go home."'

Westwood, who will face stablemate Danny Willett in the last 16 after Willett beat fellow Englishman Andy Sullivan, told Sky Sports 4: "It feels great obviously. There are no easy matches out here and I knew Jordan was going to be tough to beat.

"(I was) sliding down the bannister at the start, two down after two, and just had to regroup and fight back after that.

"Anything can happen (now). Getting out of the group was really one of the toughest things to do this week. Sometimes your fate was out of your hands but fortunately I won all three games and I am very excited about tomorrow morning.

"I will try to come out and play as good as I played today and keep holing putts."

South Africa's Louis Oosthuizen defeated Bubba Watson on the 19th to set up a clash with Rickie Fowler, but that was overshadowed by a remarkable row during the dead rubber between Keegan Bradley and Miguel Angel Jimenez in the same group.

Jimenez appeared to disagree with where Bradley had taken a drop on the 18th and, while trying to put his point across, told Bradley's caddie Steve Hale to shut up.

Hale took exception to this and Bradley - who had already asked Jimenez to "do me a favour" and walk over to his own ball - then stepped right in front of the Spaniard to say "Don't tell my caddie to shut up."

The issue was finally resolved and Jimenez won the match, but although he and Bradley shook hands, the debate was still raging and Hale refused to shake hands with Jimenez on the 18th green.

Justin Rose had earlier bowed out despite beating Ryan Palmer to claim his second consecutive victory, first-day conqueror Marc Leishman rendering the former US Open champion's result meaningless by beating India's Anirban Lahiri on the 18th to advance with a perfect 3-0 record.

Leishman will face Gary Woodland next after Woodland defeated Webb Simpson on the 18th.

Former champion Hunter Mahan also advanced to the knockout stages with his third win, the American defeating compatriot Matt Kuchar 5&4 in group 14.

Mahan will face Australian John Senden on Saturday morning, Senden and Fowler having already booked their places in the last 16 with a game to spare thanks to victories on the opening two days against the two players who could possibly match their overall record.

Head-to-head results would decide the group winner in the event of two players finishing tied, with the only play-off seeing Branden Grace defeat Zach Johnson and Charley Hoffman with a birdie at the third extra hole to set up a last-16 clash with England's Tommy Fleetwood.

Fleetwood defeated Bernd Wiesberger on the 19th and advanced courtesy of his better head-to-head record with Jamie Donaldson, who had beaten Sergio Garcia.

Elsewhere, Paul Casey had recovered from four down with nine to play to beat Francesco Molinari and set up a meeting with former Masters champion Charl Schwartzel, with Jim Furyk winning group five after beating Martin Kaymer on the 20th hole.

Furyk will take on JB Holmes on Saturday after Holmes defeated Brooks Koepka and Russell Henley defeated Scotland's Marc Warren, who would have gone through with a game to spare if he had not squandered a three-hole lead with three to play against Koepka on Thursday.