Texas has recaptured the top spot on CNBC's annual ranking of America's Top States for Business after falling to fourth last year.

The jump can be attributed to the state's significant improvement in the economy category, with Texas jumping from 25th to the top spot. After a 2016 decline, the energy sector's 2017 improvements — rising oil prices and increased drilling — contributed to the higher ranking.

Texas also had the nation’s best infrastructure, and top 10 finishes in three other categories: workforce, technology and innovation and access to capital. One in seven jobs created in the United States were created in Texas over the last year.

Gov. Greg Abbott said in an interview with CNBC on Tuesday that Texas is working to diversify its economy to make it less dependent on oil and gas. He added that the Trump administration's increased tariffs and position regarding NAFTA negotiations could temper Texas' economy, which is the top exporting economy in the country.

“We need robust trade,” he said. “If the president wants to have a good economy for the United States of America, he needs to have a reasonable trade policy that will be good for Texas. What is good for Texas’ economy is going to be essential for the American economy.”

But it wasn’t all good news. Texas was in the middle of the pack in cost of doing business and business friendliness. CNBC attributed the state’s 18th place finish in cost of doing business to high property taxes and its 21st in business friendliness to a “sometimes difficult legal climate.”

The Lone Star State also finished 37th in education, due to its low high school test scores, and 31st in quality of life, with a high violent crime rate and high percentage of people without health insurance.

Washington, last year's top state, placed second, with Utah, Virginia and Colorado wrapping up the top five. Alaska placed last in the rankings, with Mississippi, West Virginia, Hawaii and Rhode Island in the bottom five.