There's a common point of confusion: Abu Dhabi is indeed the capital of the United Arab Emirates. The confusion often stems from distinguishing between the Emirate of Abu Dhabi (the largest of the seven emirates) and Abu Dhabi City (the capital city within that emirate).
People sometimes hear "Abu Dhabi is the capital of the Emirate of Abu Dhabi" and mistakenly think that means it's not the federal capital. In fact, it's both—just like how Canberra is the capital of both Australia and the Australian Capital Territory.
Emirate of Abu Dhabi ≈ State/Province
Abu Dhabi City ≈ Capital City (of both the state and the country)
Dubai City ≈ Largest City / Economic Hub (like New York or Sydney)
So, to settle it definitively: Abu Dhabi City is the capital of the UAE. The Emirate of Abu Dhabi is the largest emirate, and its capital city serves as the nation's political heart.