The gacha system of Genshin Impact can use either items called Fates or 160 primogems for a wish. There are a LOT of ways in game to earn primogems, such as progressing the plot or performing side quests. At a certain point, you also unlock “daily commisions” that earn 60 primogems a day. You can also gain primogems (between 2 and 10) by simply opening chests or completing in-game achievements. Certain limited time events also earn you quite a bit of primogems, but many of these limited events require you to be a certain “adventure rank” first, simpler ones requiring you to be around rank 10 (when online functions activate) or around rank 40 (the current level for the plot quests) although the latter ones typically include permanent content being added as well.
The method of spending money is that you can also purchase another type of item called “genesis crystals” which have a 1:1 transference to primogems, but this is the aspect that stops it being free-to-play.
As for what is considered “haram”… any form of gambling is forbidden, aside from a few specific sports that the prophet Muhammed supposedly supported, such as horse racing, camel racing and archery. From a legal perspective, no version of the wish system (free to play or with purchase) is considered gambling as you are guaranteed an item every time you use a wish, while gambling technically requires you to have a risk of loss. That said, many gacha players consider it to be gambling if you choose to spend real world money on it, as roughly 90% of the time (in Genshin, at least) the item you receive is nearly useless. As such, I would advise simply remaining a no-spending player if you are concerned about your religion.
Incidentally, there is also a “pity” system in place. Every ten wishes is guaranteed an item of at least 4 star rarity while every 90 wishes is guaranteed a 5 star rarity item, which includes characters. This also means that, gambling or not, spending about $150 USD is a guarantee of a 5 star item while $300 is a guarantee of a advertised character or weapon on the limited time banners. There are 3 banners active at nearly any time, one being permanent and having basic weapons and characters available while two other banners, changing every 3 weeks or so, feature a set of advertised characters or weapons, including one 5 star character and 2 5 star weapons. If you keep track of your wishes (which you can see by using the tab or button on the bottom of the screen while viewing the wish banners) you can actually manage your wish rate to guarantee which character or weapon you get. For example, my current pity counter is at 72 for the limited character banner, so I am guaranteed a 5 star within the next 18 wishes. There is a 50/50 chance of receiving the advertised 5 star the first time you pull a 5 star and a 100% chance of it if you failed the last 50/50. As I failed my last 50/50, that means I am guaranteed to have the advertised 5 star character within 18 wishes, so I have decided to stop using the gacha and wait 2 more weeks for the next banner to begin, which features a new character. To this extent, even if you spend, an arguement could be made that it is never gambling since (at least) you are paying to receive a specific character or weapon of your choice.