England captain Andrew Flintoff declared his team's innings at 551-6 at tea. At stumps, Sri Lanka was 91-6 in reply, needing a further 261 runs to avoid the follow-on.
Not out when bad light ended play slightly early were Mahela Jayawardene on 40 and Farveez Maharoof with 6.
Sajid took 3-0 in nine balls as Sri Lanka collapsed, losing 4-4 in the space of 21 deliveries. The 24-year-old Sajid finished the day with 3-9 from five overs, while Matthew Hoggard had 2-14 off eight.
Pietersen hit two sixes and 19 fours on the way to 158 — the same score he made in his maiden Test century last year which allowed England to draw the fifth Test against Australia at The Oval and reclaim the Ashes.
His latest innings ended when he was out leg before wicket to Chaminda Vaas midway through the second session. He had faced 205 deliveries.
Five balls later, Paul Collingwood was bowled by Muttiah Muralitharan for 57. Collingwood and Pietersen shared a fifth-wicket partnership of 173 —a record for England against Sri Lanka.
Earlier, Pietersen was dropped on 138 when he went to sweep Muralitharan and got a top edge to a diving
Jayawardene at short fine leg. The Sri Lanka captain spilled the catch as he went to ground.
It was Pietersen's third Test century and first at Lord's after he resumed on 54 with England at 318-3.
The South African-born batsman scored 57 and 64 not out on debut in the first Test against Australia at Lord's last year, with his second hundred coming in November's second Test against Pakistan in Faisalabad.
He passed 1,000 Test runs on Friday after coming into the match with 890.
Hoggard was the only wicket to fall in the morning session when he was deceived by a slower ball from Vaas and bowled for 7 in the fifth over of the day after adding five runs to his overnight score.
Muralitharan finished with 3-158 off 48 overs, while Vaas had 2-124 off 36 and Farveez Maharoof 1-125 off 28.
Vaas nearly had Flintoff's wicket when the England allrounder — on 11 at the time — drove the ball sharply back at the bowler, who got his left hand to it but couldn't hold what would have been a spectacular catch. At the declaration, Flintoff was not out 33 and Geraint Jones was on 11.
Hoggard then struck in the third over of Sri Lanka's innings, removing Jehan Mubarak lbw for a duck before Sri Lanka had a run on the board.
A short time later, Hoggard trapped Upul Tharanga lbw for 10 to put the visiting side at 21-2. Jayawardene and Kumar Sangakkara tried to steady the innings with a stand of 60 off 103 balls.
Jayawardene escaped when he edged Flintoff behind. The ball appeared to be going between wicketkeeper Jones and Marcus Trescothick at first slip. Jones got the tip of his glove to the ball but failed to take a tricky catch.
Sajid broke the partnership with his twelfth Test delivery when he had Sangakkara caught by Trescothick for 21.
He then had Thilan Samaraweera out lbw for no score, and Chamara Kapugudera followed in the same way to his first ball in Test cricket.
In between, Tillakaratne Dilshan was run out.
Scoreboard
England (1st Innings) (Overnight 318-3)
M. Trescothick c J’dene b Muralitharan 106
A. Strauss c J’dene b Muralitharan 48
Alastair Cook c Sangakkara b Maharoof 89
Kevin Pietersen lbw b Vaas 158
Matthew Hoggard b Vaas 7
Paul Collingwood bowled Muralitharan 57
Andrew Flintoff not out 33
Geraint Jones not out 11
Extras: (16b, 7lb, 4w, 15nb) 42
TOTAL: (for six wkts, 143 overs decl.) 551
Fall of wkts: 1-86, 2-213, 3-312, 4-329, 5-502, 502-6.
Did not bat: Liam Plunkett, Sajid Mahmood, Monty Panesar.
Bowling: Chaminda Vaas 36-2-124-2 (1w), Farveez Maharoof 28-4-125-1 (14nb, 2w), Nuwan Kulasekara 25-3-89-0 (1nb, 1w), Muttiah Muralitharan 48-10-158-3, Tillakaratne Dilshan 6-0-32-0.
Sri Lanka (1st Innings)
Jehan Mubarak lbw b Hoggard 0
Upul Tharanga lbw b Hoggard 10
K. Sangakkara c Trescothick b Sajid 21
Mahela Jayawardene not out 40
Thilan Samaraweera lbw b Sajid 0
Tillakaratne Dilshan run out 0
Chamara Kapugudera lbw b Sajid 0
Farveez Maharoof not out 6
Extras: (7lb, 7nb) 14
TOTAL: (for six wkts, 30 overs) 91
Fall of wkts: 1-0, 2-21, 3-81, 4-81, 5-85, 6-85.
DID NOT BAT: Chaminda Vaas, Nuwan Kulasekara, Muttiah Muralitharan.
Bowling: Matthew Hoggard 8-2-14-2 (2nb), Andrew Flintoff 11-2-29-0 (2nb), Liam Plunkett 6-0-32-0 (3nb), Sajid Mahmood 5-2-9-3.
Umpires: Rudi Koertzen, South Africa, and Aleem Dar, Pakistan.
TV Umpire: Nigel Llong, England.
Match Referee: Alan Hurst, Australia.—Agencies