Didn't he have to fight Yoko for it?
No, because Lennon didn't own the rights to his music at the time of his death in 1980. ATV Music owned the rights from 1969 to 1981.
In 1981, McCartney had the opportunity to purchase the rights to their music for $40 million. McCartney approached Ono to see if she wanted to split the cost. She said the catalog wasn't worth more than $20 million and declined the deal. Of course this time, McCartney was worth several hundred million dollars, so he could have bought it outright. He feared looking greedy and disrespectful of Lennon's memory, so passed on the deal.
In 1982, McCartney and Jackson were collaborating on 'Say Say Say.' Jackson joined McCartney and his wife Linda for dinner. It was then that McCartney told Jackson that the only way to really make money in the music business was to own the rights to the music. He showed Jackson his portfolio and explained that he was making $40 million every year off his portfolio of their artists' songs, saying "Every time someone records one of these songs, I get paid. Every time someone plays these songs on the radio, or in live performances, I get paid."
In 1984, McCartney again had the opportunity to purchase back the rights, but declined as he thought it was too pricey.
That year, Jackson heard that ATV was up for sale and since the night of their dinner had been on a music rights buying spree. Jackson told his lawyer to spend whatever it takes to buy the Beatles catalog. In the end, Jackson spent $47 million leaving McCartney feeling betrayed by Jackson.