Bangladesh, who were playing their 100th Test match, lost opener Tamim Iqbal for 49 and Soumya Sarkar for 61 before three costly late wickets saw their progress checked to 214 for five at stumps.
The all-rounder's luck ran out shortly before tea when Dinesh Chandimal took a fine catch at mid-on, but Mosaddek - who together with Shakib put on 131 for the seventh wicket - scored 75 as Bangladesh posted 467 all out for a first-innings advantage of 129. "Tomorrow is a new day, hopefully we can get close to Sri Lanka's score".
After surviving two TV reviews on the first day, he was again given out caught behind on Thursday off Mustafizur Rahman's bowling but the decision was overturned when replays showed the ball had not touched his bat.
Tharanga finished on 25 off 35 balls, which included three boundaries, while Karunaratne remained undefeated on 25 off 43 deliveries, which included three boundaries.
'He deserved to be sacked' - Mourinho offers sardonic backing to Karanka exit
Assistant head coach Steve Agnew took over first-team duties ahead of the trip to Old Trafford. Stewart Downing was at the heart of Aitor Karanka's sacking at Middlesbrough.
Sarkar recorded his third consecutive Test fifty before being comprehensively castled by Lakshan Sandakan for 61 to leave Bangladesh 130/2. He was twice lucky in his innings after Sri Lanka captain Herath failed to review two lbw appeals which the umpires had turned down.
"I rate this is as my number one century in Test cricket so far because I batted four sessions -- I've never batted four sessions in my Test career", Chandimal said after the day's play.
Sri Lanka clawed back through Sandakan, who landed a double-strike to remove Kayes and nightwatchman Taijul Islam (0) in successive deliveries to be on a hat-trick.
Imrul Kayes made 34 before being trapped lbw by Sandakan.
Arsenal coach confirms Arsene Wenger will not leave Arsenal this summer
So overall that's our targets. "On the rest, we are in the semi-finals of the FA Cup, we have an opportunity to do that as well". Arsene Wenger admits that Arsenal can no longer "waste points" in their quest for Champions League qualification.
Chandimal, who struck only four boundaries on the opening day while helping his side recover from 70-4, batted aggressively on the second day to hit 10 fours and a six overall in his innings.
Mosaddek hit seven boundaries and two sixes in his 155-ball innings before being the last man to fall in the final session.
But Mosaddek continued the charge at the other end with a stroke-filled half-century and added 33 more with Mehedi Hasan Miraz (24) before Herath landed a double blow to cut the lower order resistance short.
U.S. charges two Russian spies over Yahoo hack
With access to the technology, the hackers spied on the contents of more than 6,500 individual users, according to the indictment. Prosecutors said they received no response to their requests to the Russian government to turn over Belan to U.S. authorities.