Farrell scored six penalties, including the winning one six minutes from time, in a hard-fought encounter at the Twickenham Stoop.
Harlequins, knocked off the top of the table when Northampton beat Wasps on Friday night, replied with an opportunist try from scrum-half Danny Care and 11 points from the boot of fly-half Nick Evans.
But the usually dependable former All Black missed three kickable second-half penalties, any one of which would have been enough to preserve Quins' 100 per cent record this season.
Evans kicked Harlequins into a second-minute lead but six minutes later he saw a second attempt rebound off the post after Sarries flanker Will Fraser pulled down a rolling maul.
Saracens drew level in the 12th minute with Farrell's simple opening penalty after Harlequins strayed offside.
Two minutes later Evans restored his side's lead with his second successful kick.
Farrell equalised again in the 21st minute after former England number eight Nick Easter was penalised for not rolling away from a ruck.
The first try-scoring opportunity was wasted by Quins. Evans found Easter but, with full-back Mike Brown outside him, the back-row man's final pass went straight into the arms of Saracens' England wing Chris Ashton.
A quick break out of defence put Sarries on the front foot when Farrell and hooker Schalk Brits combined to release Ashton down the right touchline but he was superbly tackled into touch by Brown.
Harlequins hit trouble when they lost hooker Joe Gray to injury, had lock Ollie Kohn sin-binned and fell behind to Farrell's third penalty.
Gray's game ended in the 28th minute when he was replaced for the second time by Rob Buchanan, only four minutes after returning to the pitch following a 14-minute blood-injury absence.
Five minutes later referee Andrew Small showed Kohn the yellow card for killing the ball near his own line and Farrell landed the resulting penalty.
But 14-man Quins put the misfortunes behind them when Care, looking far more lively than England scrum-half rival and opposite number Richard Wigglesworth, scored a real sniper's try.
Exploiting a rare gap in the Premiership's meanest defence, he dashed clear to touch down near the posts, leaving Evans a simple conversion.
Farrell reduced Quins' lead to a single point with a 45-metre penalty four minutes into the second half.
Then hooker Brits produced a touch of magic worthy of a half-back when he found space and directed an inch-perfect kick into the corner for the chasing Ashton but he was once again thwarted by Brown's first-class covering.
Evans missed a 52nd-minute penalty kick for Harlequins and, three minutes later, Farrell kicked the visitors ahead after Quins were penalised at the breakdown.
Evans was off-target again in the 62nd minute after Sarries' replacement prop Mako Vunipola was penalised for entering a ruck from the side.
But Evans made no mistake from in front of the posts in the 66th minute after Saracens' replacement lock George Kruis, who had only been on the pitch for 12 minutes, was yellow-carded for hands in the ruck.
Evans then missed another penalty shot before Farrell kicked the winner in the 74th minute.
Freddie Burns boosted his England hopes as his attacking spark helped Gloucester avoid becoming London Welsh's latest scalp in a 31-25 win at the Kassam Stadium.
The visitors appeared in control as they opened up an 18-9 interval lead thanks to tries from Shane Monahan and Tom Savage, with Burns involved in the creation of both scores. But Gordon Ross, who ended the game with 20 points to his name, kept Welsh in it and Franck Montanella's try looked to have set Lyn Jones' men up for a third-straight win.
However, a thrilling counter-attack instigated and supported by Burns, back after a spell in the sin bin, saw replacement prop Shaun Knight barrel over for the clinching score.
Burns and Ross had traded early penalties before the visitors landed the first telling blow. Welsh had lost hooker Neil Briggs and centre Sonny Parker to injury when Burns struck his second penalty before producing two moments of brilliance to create the opening try.
Burns then caught the hosts sleeping as he took a quick tap to allow the powerful Monahan to get over on the right. Ross responded with a penalty for Welsh but It proved a brief reprieve as more good work from Monahan and wing partner James Simpson-Daniel laid the platform for Savage to barge over after Burns had gone close.
Ross again responded with a penalty but Welsh were being forced into ill-discipline as they struggled to contain Gloucester's desire to put tempo on the game. They were also guilty of failing to convert two excellent tryscoring chances.
Moments into the second half Ross failed to get his pass away with several men free outside him as Burns stepped in and was adjudged to have deliberately knocked on.
That saw the Gloucester man binned and Ross kicked his fourth penalty, but Welsh infringed moments later after failing to secure their own line-out ball to let Billy Twelvetrees reinstate the nine-point gap between the sides.
When the Exiles did manage to win set-piece ball their rolling maul was proving a handful for Gloucester, and one such surge led to Ross' fifth penalty. The hosts then took the lead after more strong work from their pack. Several drives took them close to the line before Montanella was adjudged to have grounded the ball beneath a pile of bodies.
Ross converted for a one-point advantage and quickly added yet another penalty after Sione Kalamafoni was penalised for attempting to hurdle a pair of London Welsh defenders. But Burns replied with his third penalty and then superbly created Knight's winning try to cement the win.
- Nick Evans