George Ford scored an impressive solo try for the visitors but a five Madigan penalties had Leinster leading 15-5 at the interval.
Stuart Hooper grabbed Bath's second try after the restart but Madigan's sixth penalty put the hosts six points clear, Leinster holding on despite a Ford three-pointer in reply to set up a final-four clash with reigning champions Toulon.
The result keeps Leinster in the hunt to become champions of Europe for a fourth time in seven years, but whatever happens between now and then captain Jamie Heaslip insists his troops can hold their head up high after triumphing against Bath.
"We can take a lot of positives out of it," he said. "They're on our line, they're 25 metres out in that last minute and a half, two minutes of the game.
"Someone asked me was that the experience part; a little bit of experience and a little bit of the lads showing their character. I couldn't be prouder of them.
"If you make any kind of individual or system errors, Bath are going to punish you. And that happened twice. There were probably a couple of other times where they really did stress us and make line breaks, or half line breaks."
While Leinster are the only GUINNESS PRO12 representatives in the European Champions Cup, there was plenty of interest in the Challenge Cup with all but one quarter-final not featuring a GUINNESS PRO12 team.
The big clash was at Rodney Parade as Welsh rivals Newport Gwent Dragons and Cardiff Blues did battle.
The Dragons found themselves 14-3 behind after Lloyd Williams and Gareth Anscombe both crossed for Cardiff tries.
But the home side roared back through Hallam Amos before the break before Nic Cudd earned a penalty try for the narrow win.
And former Blue turned Dragons captain T.Rhys Thomas reckons they were rewarded for sticking to their winning formula.
"The start didn't go to plan but the try just before half-time was crucial and gave us the momentum," he said.
"The ten minutes either side of half-time shaped the game. I am proud for them really, especially players like James Benjamin, Nick Crosswell.
"There were a lot of eyebrows raised when the team was announced with Faletau and Nic Cudd on the bench but that's where we are trying to get to.
"When the boys have been missing - Cuddy injured and Faletau in the Six Nations - we had a couple of wins, Ulster and Kinsgley and Lyn kept faith in the team. That confidence gives a massive boost to the boys with the shirt."
The Dragons will face another GUINNESS PRO12 team in their semi-final with Edinburgh getting past London Irish 23-18 at the Madejski.
Edinburgh raced into a 16-0 lead thanks to a converted WP Nel try and three Sam Hidalgo-Clyne penalties, although the Exiles trailed by just six points at the break thanks to a Shane Geraghty penalty and Conor Gilsenan's try.
London Irish then led when Scott Steele crashed over, but Edinburgh responded through Fraser McKenzie - much to head coach Alan Solomons' delight.
"I thought the side showed tremendous character and tremendous commitment to come through that game," he said. "And to be honest with you, they absolutely deserve it.
"For the first 20 minutes we dominated, there was like a lull for 12, we got 16 points, but between the 32nd and the 52nd minute Irish completely dominated.
"It was a total swing in the momentum of the game, which you have, and then we managed to get back in through Fraser McKenzie with that try and then we had that drama at the end."
However there was bad news for Connacht who failed to progress, losing 14-7 at Gloucester's Kingsholm Stadium.
Connacht trailed 14-0 at half-time as the hosts scored tries through Charlie Sharples and Bill Meakes, and while they refused to lie down and halved the deficit with a penalty try, it proved nothing more than mere consolation.
Follow us on Facebook, join the conversation on Twitter, sign up to our YouTube channel for extensive match highlights and sign up for our newsletter for regular updates on the GUINNESS PRO12