Jay Z and Beyonce got the last laugh after getting notice to leave the house they were renting … because we’ve learned they got an even better house.

Our sources say Bey and Jay are now renting the $45 million Holmby Hills palace that was owned by ex-L.A. Dodgers owner Frank McCourt.

McCourt sold the house to a British billionaire last year for $45 million, but we’re told the new owner was hardly in L.A. and it just sat vacant. So he recently decided to put it on the market for lease … we’re told for around $150k a month.

Our sources — all of whom are people who were on hand this past weekend facilitating the move — say Beyonce and Jay signed a 1-year lease.

As for the house … it’s 20,000 square feet, complete with an indoor Olympic-sized pool complex and an outdoor pool with a waterfall and formal gardens.

As we previously reported, Bey Z got the boot from their old rental in the same neighborhood after the owner decided to sell it.

We broke the story … Jay Z and Beyonce are putting down stakes in L.A., largely because they think it’s a good place to raise Blue Ivy.