Between insurance, gas prices and upkeep, maintaining a car is a long-term expense: The costs of ownership don't stop when your loan or lease is paid off. And, depending on what state you live in, those expenses can be much higher or lower, according to industry analyses.

The most expensive state to own a car, for example, is Michigan, where the average cost for three years of ownership is $16,239.29. That's a more than $6,000 difference compared to the cheapest state of New Hampshire, where the average three-year cost is just over $10,000.

Financial website GOBankingRates collected data from AAA.com, CarInsurance.com, CarMax.com, CarMD.com, individual state Department of Motor Vehicle sites, Kelley Blue Book and the National Conference of State Legislatures, to determine the costs of owning a car in all 50 states. The data totals the cost of buying and owning a car for three years for the following six metrics: annual gas costs, assuming you fill up a 14-gallon tank once a week; annual insurance premiums; car sales tax; average maintenance and repair; and title and registration fees.

Based on that data, here are the 10 most affordable states to own a car: