As far as a mortgage is concerned you'd need to talk to your bank. They may be prepared to write a mortgage for one of you but they would likely look at the finances of the other person too whether or not they are on the mortgage, even more so if one person is lending money to the other to enable the purchase to go ahead.
So there's rarely an advantage to being a first time buyer as far as a mortgage is concerned, being a first time buyer is mainly an issue for Stamp Duty. And as far as Stamp Duty is concerned, married couples and civil partners are counted as one whether or not you buy a house singly or together. So partner Y would be counted as owning an interest in that property too by dint of their marriage or civil partnership and therefore not entitled to the first time buyer discount on stamp duty.
In order to qualify for the discount both parties would need to be able to state truthfully that they had never owned a residential property at any point.
Here's an official confirmation of the one unit rule although that is talking about purchasing additional properties it does say it applies in all cases.
The government will treat married couples and civil partners living together as one unit. This is consistent with other areas of the tax system including Capital Gains Tax private residence relief where married couples are entitled to relief on one residence between them.
If you want more confirmation, here's a more direct statement from the Home Owners Alliance that says the same thing.