England captain Andrew Strauss will mull over the decision to enforce a follow-on overnight.
The hosts earlier made 419 with Ian Bell making 128 and sharing a stand of 153 with Matt Prior (93), but an opening partnership of 126 between Tamim and Imrul Kayes provided encouraging signs for Bangladesh.
But after being switched to the Stretford end at Old Trafford, Swann began to weave his magic with the first of his five wickets arriving when number three Junaid Siddique nicked one through to Prior.
Swann soon wrapped up the innings with the important wicket of Mushfiqur Rahim, snapped up at slip by James Anderson, with just 90 runs added for the last nine wickets.
"Obviously going up to tea things weren't going great for us," added Swann, who finished wicketless in the opening Test at Lord's last week.
"We regrouped and had a discussion with our bowling coach David Saker and came up with a plan that worked perfectly.
"You never expect to take 10 wickets in a session, that is outstanding and I can't remember that happening in my career.
"We hoped once we got one we could get two or three so we are delighted to be where we are now."
Tamim, who followed up his Lord's ton by smashing his 108 from 114 balls, was disappointed his team-mates did not perform at the crease.
"Personally, it was good to score back-to-back hundreds but the team matters - and the team didn't play that well," said the 21-year-old, who revealed he had suffered chest pains during his innings after being hit by the ball.
"I could be very happy but I'm not because we're all out and we wanted to put up a better show. We need to think about the next innings and put up a better show."
Having become the first Bangladesh batsman to score back-to-back Test centuries, he added: "Both hundreds were special. I think this one was very good because there were some tough periods.
"They were bowling very good line and length, so I was just waiting for [the ball to come into] my areas."
And regarding facing the spin of Swann, Tamim said: "I was not having any problem but he bowled really well compared to Lord's where there was no turn. I was just enjoying myself, I never think about the bowlers.
"I didn't do my job because with 20 overs to go, I should have been batting there [at the end]."
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.