Upvote:5
You don't need a visa to transit, as long as your transit is less than 24 hours - yours is 12 hours so no issues there.
You can spend time airside in the large transit lounge. There is a hotel, plenty of shopping and places to relax, eat and even take a shower if you so please.
You won't be boarded if you are not eligible for transit, so there is no risk of being "stuck".
Relax, and enjoy your trip.
Upvote:10
According to a Timatic search using the United Airlines interface, you can transit without a visa.
Searching for a Afghan national transiting in the Emirates yields:
United Arab Emirates - Transit Visa
Visa required.
Transiting without a visa is possible for:
Holders of confirmed onward tickets for a max. transit time of 24 hours.
Visa is required for transit between Dubai International Airport (DXB) and Dubai Al Maktoum International (DWC).
So if you have an onward ticket for a transit under 24 hours, and you don't need to change airports, you're fine.
BTW, even Israelis, who certainly can't get a visa for Dubai (without very special circumstances), can transit there without a visa, and routinely do so.