In their traditional senses, masterful means imperious or domineering, and masterly means with virtuosic skill. But the original meaning of masterful has all but disappeared, and the two words are now used interchangeably. Moreover, masterful has taken over much of masterly‘s territory and appears to be pushing the latter word out of the language.1
Careful writers are free to honor the original sense of masterful, but this might just cause confusion.
Examples
For example, these old instances of masterful wouldn’t make sense to anyone unaware of the word’s original meaning:
The only school befitting his absolutely convinced and masterful spirit is one in which he reigns supreme. [Samuel Thurber, 1901]
He loved women in his masterful way, marrying three beautiful wives in succession and clinging to each with a certain desperate, even if unsympathetic, affection. [W.E.B. Du Bois, 1896]
His words were masterful, his gestures commanding, his shoulders erect and kindly. [E. Pauline Johnson, 1913]
These examples demonstrate how modern writers use masterful (i.e., as a variant of masterly):
Aaron Sorkin’s screenplay is masterful, concentrating above all on character, but never losing sight either of plot, structure, or wit. [Telegraph]
Bogle is masterful in describing how the Depression affected black performers … [Boston Globe]
His comments acknowledge the Republicans’ uphill climb against an incumbent president and masterful campaigner who never really shut down his political machine. [Winnipeg Free Press]
On the web, instances of masterful already outnumber masterly by a large margin, and masterly is likely to continue to fade. Though we all want to be careful writers—and losing a good word is always unfortunate—this is one of those changes to the language we’ll probably have to accept.
References
1. Google Ngram charting the decline of masterly in English-language books ^

