Australia, skittled for just 88 on the opening day, fared better in the second innings.
Resuming at 136 for two on Friday, Steven Smith scored an enterprising 77 off just 100 balls between lunch and tea, with nine fours and two sixes, to boost Australia's hopes after Michael Clarke made 77 and captain Ricky Ponting hit 66.
But with only a small lead to defend, Ponting was let down by his bowlers, Mitchell Johnson in particular.
Shane Watson, who claimed a test best six for 33 in Pakistan's first innings, allowed ten runs off his fourth over, including two leg-glanced boundaries by Farhat to ill-directed balls outside leg stump.
Even the Australian fielding was ragged at times as Ben Hilfenhaus's fumble on the third man boundary cost two after an Ali cut off leg-spinner Smith.
Farhat raised his half-century with a square cut off a short and wide Johnson delivery for one of his nine boundaries.
However, Australia's Smith said his side had not given up hope of salvaging something from the match.
"We'll see how it goes in the morning. We've got to believe in ourselves. Hopefully, we can get a few wickets and put a bit of pressure on," he said.
The Test series is being played in England after international cricket in Pakistan was effectively suspended after an armed attack on Sri Lanka's team bus in Lahore in March last year.