The opposite of 'at the beginning' is 'at the end'.
I go to the gym and train 3 times a week.
I train on the bicycle and on the threadmill at the beginning of my
training. I do some stretching of muscles at the end of training.
[ Players shake hand at the end of football/ice hockey match.]
We could use 'in the end' to say the final phase or final part of something.
I sold my car recently. At first, there were a lof of offers. It took
some time to made the decision. In the end I sold it to a person
in my neighbourhood.
In the end means finally.
The opposite of 'in the end' is 'at first'.
[ I hope Clive and the other native speakers will toe the line with me; I am not a native speaker of English.]