T-Mobile CEO John Legere is making contingency plans in case a long-rumored buyout offer from Sprint falls through, The Post has learned.

The nation’s fourth-largest wireless carrier is making offers to buy valuable spectrum from smaller rivals even though Legere might have to resell some of that same spectrum if a merger with Sprint passes regulatory muster, said a source familiar with the situation.

“Buying spectrum would add to the potential divestitures resulting from the combination,” the source said.

Nevertheless, T-Mobile has delivered proposals to several wireless carries offering to buy their so-called low-band spectrum — the key to urban markets like New York City because it penetrates buildings better than the high-band variety.

In April, T-Mobile completed a $3.3 billion acquisition of low-band spectrum from Verizon. Before the deal, T-Mobile was the only major wireless carrier without such spectrum.

The swath of 700 MHz A-band spectrum covers about half the country, and T-Mobile could start filling in the rest of its footprint, sources said.

Most of the other 700 MHz A-band spectrum is spread among about 33 relatively small carriers, including US Cellular and Paul Allen’s Vulcan Inc.

AT&T would be the other most likely buyer for this spectrum, but it is busy trying to acquire satellite-TV provider DirecTV.

“[T-Mobile] could be trying to push for this spectrum now before reaching the Sprint deal,” the source said.

Sprint parent SoftBank is expected to make a formal offer for T-Mobile in July or August and reportedly has agreed to a massive $2 billion breakup fee in the event antitrust regulators nix the combo.

T-Mobile has been at a huge competitive disadvantage not owning low-band spectrum, and it needs to act independently as if there were not going to be a merger, said one source.

A T-Mobile spokesman declined comment.