Tony Pulis’ side were facing a sixth-place finish and a semi-final against Fulham after falling 2-1 behind when Martyn Waghorn struck from the spot seven minutes from time at Portman Road.
But Bamford levelled deep into time added-on, a goal which lifted Boro back above Derby and into fifth in the second tier, securing a clash with Steve Bruce’s Aston Villa, with the first leg to be held at the Riverside next Saturday.
It was the second time Middlesbrough had come from behind, with Stewart Downing’s 71st-minute strike cancelling out Freddie Sears’ early goal.
Middlesbrough had won each of their last three matches while the Tractor Boys were looking to capitalise on thrashing Reading last weekend.
The hosts made a positive start as neat interplay between Cole Skuse and Waghorn led to the latter shooting into the side netting. Waghorn also struck the outside of the post from a corner soon afterwards.
Ipswich went ahead in the eighth minute when Sears broke free of a tackle by Boro defender Ben Gibson wide on the right and ran in on goal to fire a perfect shot past goalkeeper Darren Randolph.
The visitors’ first meaningful strike at goal came in the 16th minute following persistent pressure which culminated in Muhamed Besic firing over the bar.
Then Ipswich defender Adam Webster deflected a cross from Downing just past the post in the 33rd minute. And from the resultant corner Middlesbrough nearly equalised following a goalmouth scramble which ended with Callum Connolly clearing the ball off the goal line.
The visitors began the second half as they ended the first with much of the possession but the Ipswich defence held firm.
In the 57th minute an appeal for handball in the penalty area by Ryan Shotton was turned down by referee David Coote and then Randolph produced two wonderful saves to deny the home side.
He first tipped the ball over the bar from a Waghorn shot following a cross by Sears and, from the following corner, did similar to a goalbound shot by Skuse.
But Middlesbrough equalised in the 71st minute through Downing, who fired through a crowded penalty area following a corner by Adama Traore.
Substitute Shane McLoughlin made an immediate impact in the 83rd minute when he charged down a clearance by Daniel Ayala and was fouled in the penalty area by Ben Gibson. Waghorn stepped up to convert the penalty.
Good chances by Britt Assombalonga and Bamford in injury time were kept out by the Ipswich defence.
Ayala thought he had grabbed the leveller when he volleyed home after Besic had struck the bar, only for the effort to be chalked off for offside.
The away side would not be denied, however, and Bamford struck right at the death when he headed home.