The defense industry begins 2020 in a similar climate as the one that existed at the beginning of the last decade. The U.S. government is divided, leading to budget uncertainty and the risk of procurement slowdown. The U.S. deficit remains an important political issue, and Pentagon spending a natural target.

Defense stocks have had a great run, with the SPADE Defense Index returning 107.9% over the past five years, easily besting the S&P 500's 61.87% return. Given that success, and the ambiguity that usually comes in a U.S. election year, it's only natural for investors to be more selective about the sector heading into 2020.

^DXS Chart

Defense vs. S&P 500 data by YCharts.

This is the sort of market environment where it's best to pick companies with either sustained competitive advantages, or factors that make them likely to overperform relative to their peers, instead of simply buying a basket of stocks in the industry.

Here's why Lockheed Martin (NYSE:LMT), Booz Allen Hamilton (NYSE:BAH), and General Dynamics (NYSE:GD) are the three best defense stocks to buy heading into 2020.

Lockheed Martin: Top portfolio at a reasonable price

Lockheed Martin shareholders enjoyed a 30% gain in 2019, fueled by the world's largest pure-play defense contractor's sprawling portfolio of products that address some of the Pentagon's most pressing needs. Lockheed Martin's key offerings figure to remain in demand even if the Defense Department is forced to make difficult spending choices. And most of them are still in the early stages of growth, which means they can propel the stock higher in the years to come.

Lockheed Martin's signature products are its warplanes, with the company winning both of the major U.S. fighter design competitions held so far this century. The F-35 Joint Strike Fighter is its flagship, a plane with the potential to be a trillion-dollar program for the company and its subcontractors over its life span, and it is just now reaching full maturity and ramping up orders.

An F-22 in flight

Lockheed Martin's F-22 Raptor flies over Georgia. Image source: Lockheed Martin.

Critics once worried that the F-35 was so dominant Lockheed Martin was becoming overly reliant on the plane as a source of revenue growth, but in recent years, the company has made the case that that's far from the truth. Lockheed Martin is the most important defense contractor involved in hypersonics -- missiles capable of traveling more than five times the speed of sound -- winning more than $4 billion in new contracts since the beginning of 2018.

The Pentagon considers hypersonics a priority because it's an area where Russia and China are on par, if not ahead, of U.S. efforts. The government typically likes to spread contracts around to various companies in order to encourage a robust supply chain, but in 2018, when Pentagon officials were making awards to Lockheed Martin, they concluded that "no other contractor has this level of design maturity," an important public endorsement of the company's efforts.

Lockheed has spent the last few years revamping its portfolio and shedding some of its government IT and logistics businesses while acquiring Sikorsky Aircraft from United Technologies. The U.S. Army hopes to refresh its helicopter fleet in the early part of the 2020s, and Sikorsky is in a strong position to win at least one if not a number of planned multibillion-dollar competitions.

Lockheed Martin is also a leader in missile defense, manufacturing the THAAD anti-ballistic system deployed to counter North Korean threats as well as the PAC-3 missile that makes Raytheon's Patriot missile defense platform work.

LMT PE Ratio (TTM) Chart

Defense valuations data by YCharts.

Add it all up, and Lockheed Martin offers investors a superior portfolio of assets and an industry-best dividend yield, all at a multiple that is in line with its peers. Factor in the potential for growth at many of Lockheed Martin's most important divisions, and the company remains one of the industry's best buys.

Booz Allen: Quiet dominance

Booz Allen Hamilton is one of the original so-called "Beltway Bandits," a collection of companies that have sprung up to provide support, and in recent years outsourced services, to the ever-growing federal government. The company was created in the 1910s to provide outside consulting and research to corporate clients, but it pivoted toward the government after World War II.

The modern company is perhaps best known as the former employer of Edward Snowden, but Booz Allen today provides a wide range of consulting, IT, engineering, and cyber services for government, healthcare, and energy clients. Earlier in the decade, Booz Allen was dubbed "the world's most profitable spy organization" due to its post-9/11 growth.

Three soldiers in the field with a laptop and other communications equipment

Technology is playing a more important role on the battlefield. Image source: Getty Images.

Nearly 50% of 2019 revenue came from defense and another 23% from intelligence, with the rest split between civil agencies (26%) and commercial business.

Booz Allen shares have nearly doubled over the past three years, riding a wave of government procurement growth that followed years of Washington budget battles and sequestration. Heading into 2020, the company looks well-positioned to continue that momentum. Its Vision 2020 strategy, introduced in 2015, has positioned Booz Allen as the go-to vendor in areas including artificial intelligence, blockchain, directed energy weapons, and cybersecurity.

The primary criticism government services companies face from investors is that outsourcing is a race to the bottom, and it is hard to generate sustained margins from the business. Booz Allen believes that by building its tech expertise and intellectual property in areas like AI and cybersecurity, it can differentiate itself and get less-commoditized, more lucrative contracts that demand cutting-edge knowhow in these areas.

BAH PE Ratio (TTM) Chart

Government services valuations data by YCharts.

Booz Allen shares have nearly doubled over the past three years, and the company is guiding for nearly 10% organic growth in 2020. But despite the lucrative nature of its potential and that industry-leading guidance, the shares are reasonably valued compared to the company's competitors. Booz Allen's momentum is sustainable.

General Dynamics: On the mend

General Dynamics has been the sleepy prime contractor in recent years. It's been the laggard of the group due to issues in certain parts of the portfolio. Also, GD lacks big-ticket platforms that are in the more lucrative production phase versus the costlier R&D phase.  But the company is also well-positioned to benefit from some of the trends that should fuel Lockheed Martin and Booz Allen higher, and it offers revenue diversity that should be a hedge against election-year budget battles or other Pentagon funding issues.

The company's Gulfstream business jet unit has been the albatross around General Dynamics' neck, with the biz jet industry still struggling to regain its footing nearly a decade after the Great Recession. But a combination of changes in depreciation rules and an aging corporate fleet has breathed life into biz jet sales, and Gulfstream has a refreshed portfolio to sell into the upswing.

An illustration of a submarine underwater, deploying its weapons

General Dynamics Virginia-class submarine. Image source: U.S. Navy photo illustration.

Expect 2020 to be the year that Gulfstream moves from a headwind to a tailwind inside the General Dynamics portfolio as the new G500 and G600 planes get airborne. I expect in the next 12 to 18 months, Gulfstream will become a major profit center for GD even if Pentagon procurement operations are not affected by the presidential election. It could be a powerful offset should politics get in the way and slow defense spending.

General Dynamics' military portfolio suffered from declining margins in 2019 due largely to the number of early-stage projects the company has on the books. Older contracts tend to be the most profitable; newer programs like the Navy's Columbia-class ballistic submarine, expected to be the most expensive new boat program on record, tend to compress margins initially because of the research and development and the tooling that go into new work.

That mix is going to take time to mature, but expect to see improvements as 2020 continues. The company should also be able to eventually recover billions in lost revenue after Canada blocked an armored vehicle sale to Saudi Arabia, and it has a large and powerful IT business that's winning share from smaller competitors.

General Dynamics expects free-cash-flow conversion of more than 100% in 2019, meaning the net income it's reporting is turning into cash, and the company expects to generate more than $3 billion in free cash in 2020. That should be more than enough to support the industry's second-best dividend yield (trailing only Lockheed Martin) and allow it to be opportunistic should it see a potential acquisition.

LMT PE Ratio (TTM) Chart

Defense valuation metrics data by YCharts.

It seems everything that could go wrong has gone wrong for General Dynamics in the last few years, and as a result, the company trades at a discount to its peers. As that changes, the company is poised to outperform.

Choose carefully

All of the major defense companies have stable backlogs and key positions on platforms that should generate revenue well into the 2020s, meaning the industry should be able to weather a budget slowdown should priorities change following the 2020 election. But if the past is a guide, expect increased volatility in the defense sector as the election drama plays out over the course of the year.

There is no reason for investors to avoid the defense sector, but it would be wise to try to select stocks that have catalysts that can help power them higher even in difficult conditions. Lockheed Martin, Booz Allen, and General Dynamics are among the best the industry has to offer heading into the new year.