In a year marked by historic economic development deals and marred by a damaging trade war, Virginia lands at the top of CNBC's 2019 ranking of America's Top States for Business. This is the Old Dominion's fourth win in the 13 years since the study began. In fact, Virginia was CNBC's inaugural Top State in 2007. But this is its first win since 2011. That year began a five-year leveling off in defense spending — a key part of the economy in Virginia. Defense spending accounts for nearly 12% of the Commonwealth's GDP, more than any other state, according to the National Conference of State Legislatures. Now the Pentagon's budget is back in a big way, rising to $686 billion for fiscal year 2019. In the state where the Pentagon is located, that is welcome news. But Virginia's success involves much more than the military. The state offers the best workforce in the country, reveals our 2019 study. Nearly 38% of adults have a bachelor's degree or higher, according to the U.S. Census Bureau, placing Virginia in the top 10 for educational attainment. And per the U.S. Bureau of Labor Statistics, Virginia has the nation's fourth highest concentration of crucial science, technology, engineering and math (STEM) employees, making up 9% of the workforce in 2018. All of this in a right-to-work state with a minimal union presence — something companies prize.

Aerial view of The Pentagon in Langley, Virginia. Getty Images

That workforce was a key factor in Virginia's biggest economic development win in recent memory: Amazon's decision to locate a portion of its coveted HQ2 project in Arlington, announced late last year. The retailer promises to ultimately hire 25,000 people for Virginia's part of the facility and to spend $2.5 billion. "We were really excited by Virginia, what it had to offer," said Brian Huseman, Amazon's vice president for public policy and part of the core site selection team, in an interview with CNBC. "Probably the most important thing was the attraction of this place to talent, and particularly tech talent." Workforce is the most important category in the CNBC study. Huseman also pointed to Virginia's focus on education, which he said was unique among the bids. Virginia Tech University plans to open a new "innovation campus" adjacent to the site.

We were really excited by Virginia, what it had to offer. Probably the most important thing was the attraction of this place to talent, and particularly tech talent. Brian Huseman Amazon's vice president for public policy and part of the core site selection team

During his gubernatorial campaign, Ralph Northam greets supporters at an election-night rally on Nov. 7, 2017, in Fairfax. Win McNamee | Getty Images News | Getty Images

But it is Northam's own past that has raised concerns about another aspect of Virginia's business climate: inclusiveness. Northam faced widespread calls to resign in February after his 1984 medical school yearbook page surfaced showing one person in blackface and another in Ku Klux Klan robes. Northam has denied that either of the individuals is him, but a subsequent investigation was inconclusive. He refused to resign, calling the incident an opportunity to heal the state's fractious racial past and promising to devote the rest of his term to racial equality. Since then, his administration points to a number of initiatives, including setting a goal to eliminate the racial disparity in the state's infant mortality rate by 2025, a program to reinstate suspended driver's licenses that began this month, and setting employment equity targets for state agencies. Northam also established a commission to examine racial inequities in state laws. The CNBC study measures inclusiveness based on antidiscrimination laws as part of a state's Quality of Life score. Virginia ties with California for 17th place with a grade of C+. The state does have strong legal protections against most forms of discrimination, but no explicit prohibition of discrimination on the basis of sexual orientation or gender identity. Another weak spot in the Top State is costs. Those smart workers command big salaries, and wage costs in Virginia are the 10th highest in the country, according to the Bureau of Labor Statistics. The state finishes 35th for Cost of Doing Business and 32nd for Cost of Living — and that is before Amazon comes to town.

The contenders

Texas finishes second in the rankings following its fourth Top States win in 2018. The state is still a business leviathan that has never finished outside the top five in our study. But Texas is no match for declining oil prices, which sap the state of its economic lifeblood. Crude oil prices are down roughly 20% from their peak last fall. Also hurting Texas is the trade war, which is sapping exports and imports. North Carolina finishes third in this year's rankings, thanks to a supremely well-rounded economy that we rate the best overall. While economic growth was moderate at 2.9% last year, other measures of economic strength are solid. The housing market is healthy, with prices rising nearly 7% last year, according to the Federal Housing Finance Agency. Foreclosure activity is down, and fewer than 10 percent of mortgages are underwater, claims Attom Data Solutions.

Utah's Silicon Slopes is buzzing with potential. John Pulsipher | Getty Images

Finishing fourth is Utah — another perennial favorite in the rankings. The Beehive State's economy is buzzing. State GDP rose 4.3% in 2018. That is the second highest growth rate in the nation. The Silicon Slopes technology region keeps growing, attracting prized STEM workers to the Wasatch Front. But the state continues to lag in Education, with the nation's largest class sizes and the second smallest per-pupil spending. Rounding out the top five is Washington State. It had America's fastest-growing economy last year, at 5.7%. But that growth is taking its toll. Longstanding infrastructure problems are worsening. The state falls to No. 39 in the category from No. 31 last year, earning a dismal C-. Nearly one quarter of the state's roads are in less than acceptable condition, according to U.S. Department of Transportation data.

On the fast track

This year's most improved state is Kansas, rising 16 spots to No. 19 overall. Two years after state legislators ended an experiment in extreme supply-side economics, including deep tax cuts championed by then-Gov. Sam Brownback, state finances have improved. Kansas is running a surplus now, and services are being restored. "We are returning to our roots as a very progressive, thoughtful, forward-looking state," Gov. Laura Kelly told CNBC in an interview. Kelly, a Democrat, won the governorship last year in part due to the backlash over the state's economic woes. But nonpartisan state budget forecasters warn that repealing the tax cuts alone will not solve Kansas' problems. In fact, forecasts call for revenues to begin declining as soon as next year. Even Kelly has acknowledged that the state's finances need to be overhauled. Other states that better themselves in 2019 include North Dakota, rising 12 spots to No. 17 overall, with solid improvements in Workforce, Economy and Education. No. 3 North Carolina vaults into the top five from ninth place last year, thanks to solid improvement in Economy. Nebraska also rises six places, to No. 8 overall, on the back of an improving economy. As a farm state, Nebraska is particularly vulnerable to the trade war. But it has weathered the storm for now. The year's biggest decline belongs to Michigan, which falls 13 spots to No. 24 overall. A cooling housing market is hurting the state's economy, falling road quality is hurting the state's infrastructure, and the state's workforce development efforts are falling short. Other decliners include California, falling seven spots to No. 32. The Golden State's economy is still among the fastest growing in the country, but the housing market has cooled considerably. Idaho (No. 18) falls seven places as well. There, the economy is cranking along and the housing market is on fire. But that growth is leading to rising costs. Massachusetts (No. 14) and Pennsylvania (No. 28) each dropped five spots. Massachusetts slips in Workforce, Economy and Infrastructure. Pennsylvania's Workforce ranking plunges to 31 from 13. The state's unemployment rate — 3.9% in May — is now roughly in line with the national average. That means fewer available workers.

State laggards

If there are top states, there must be bottom states, and this year's also-rans will be familiar to any longtime followers of this study. West Virginia improves slightly to No. 45 from No. 48 this year. But the state still turns in a dismal performance in areas like Technology & Innovation and Business Friendliness. Louisiana slips two spots to No. 46. The state is heavily dependent on energy, and falling prices hurt. Similar story for Alaska (No. 47), though the state rises from last place one year ago. The state's budget picture has improved considerably, following an overhaul of state finances, and the housing market has improved. But it is not enough to overcome the state's many other woes, including high costs and poor infrastructure. Right behind is Mississippi, with an economy that's barely breathing. The state ranked No.48 due also to persistent quality-of-life issues, most notably poor health.

Mississippi has the second-highest obesity rate in the nation. Rogelio V. Solis | AP

Hawaii falls two spots to No. 49 on this year's list, perpetually hampered by high costs and poor infrastructure. But the Aloha state regains its No. 1 rank in Quality of Life after a brief stumble last year when it fell to second place because of high crime. Rhode Island rounds out our 2019 rankings — the fifth time in 13 years that the Ocean State has finished last. The state is mounting an ambitious program to fix its crumbling infrastructure once and for all, funded by tolls on interstate trucks. Officials point to $1.5 billion in road work over the past three years, and 180 bridges repaired or replaced. But the improvements are not showing up in the numbers yet, at least relative to other states. Simply put, Rhode Island was so far gone that any comeback effort will take time.