After you submit a manuscript to a journal, it can take a long time before it is accepted for publication. I have written before about how to find out for a specific journal how long it might take from submission to acceptance. Here I describe the publication process: what happens after you submit your manuscript for publication.
Before submission
To improve the chance of getting your manuscript accepted for publication, you should select journals that are most suitable to publish your work in. There are various tools available to help you choose the right journal. Once you have selected a journal, you need to format your manuscript to match the journal's style guide. For each journal, you need to adhere to, among others, specific maximum numbers of words of main text and abstract, a particular format of the citations, a particular format of the references, and a particular style of graphs and tables. Make sure you carefully read all the instructions to comply with their rules.
Once you try to submit the manuscript in the submission portal (editorial manager), many additional requirements may pop up. Suddenly, you need to provide things such as all authors' affiliations, email addresses, and telephone numbers, upload a signed conflict of interest form for each author, provide a cover letter, and suggest potential reviewers.

After the submission
Once you hit the submit button, the waiting starts. Your manuscript will arrive on an editor's desk and this editor will have a quick look at it. If they do not like it at first sight, do not think your manuscript fits the journal's scope, or already have too many submitted articles on their desk, they may decide to reject the manuscript right away. You will receive a rejection in no time, within a few hours or a few days. In that case, go back to the list of journals you initially selected and reformat your manuscript for the next journal on your list.
When the editor does not reject the manuscript right away, it will be sent out for review. The editor will then select 3-4 reviewers and invite them to peer review the manuscript. The selection of peer reviewers takes some time as the editor will need to do some research for this. The reviewers will also take a couple of days to either accept or reject the invitation. It can be hard to find peer reviewers. Once a reviewer accepts the invitation, they will have 2 to 4 weeks to read the manuscript and write the review. Peer reviewers sometimes ask for extensions when they are pressed for time, thus delaying the process.
First decision
Once the editor receives, ideally, about three reviews, they will make a first decision. The decision can be to reject, revise, or 'accept as is'. If your manuscript is rejected, it may feel like you are back to square one. However, this is not the case, as you can now improve your manuscript based on the reviewers' comments before submitting to the next journal.
If your manuscript is sent back for revision, the number of weeks you are given to revise your manuscript depends on whether a minor or a major revision is needed. Keep in mind that you can always ask for an extension and that these are usually granted. You can read here what is expected when you are asked to revise your manuscript and write a reply to the reviewers' comments. The best outcome of the review process is an 'accept as is' decision. Unfortunately, this rarely happens in the first round.
Resubmission after revision
If you had to revise your manuscript and it was a major revision, the original peer-reviewers will be asked to re-review it. They can then advise whether they think the manuscript is now acceptable for publication, should undergo another round of revision, or is not acceptable for publication. If a minor revision was required, the editor may have a look at the revision and decide. Either way, within a couple of days or weeks you will hear back from the editor.
Hopefully, after one round of revision, your manuscript is accepted for publication. The manuscript will then be sent to the copy editor, who may make changes to the language and style and will typeset it. Next, you will receive a PDF to proofread and sometimes a list of queries to answer. Very carefully compare every word, graph, and table in the PDF with those in the manuscript you submitted. Because on occasion, weird things can happen: a paragraph is missing, an abbreviation has been interpreted wrong, all your Greek letters have turned into boxes, etc. Sloppy proofreading can lead to hilarious mistakes, as you can see here, but can also mess up an article.
If you are happy with the proof or only minor corrections need to be made, your article will soon be published online. When substantial corrections need to be made, make sure you demand to see another proof before the article is published. If everything goes well, you will find your article published online in a few days or weeks.

1. In publishing, if in the past you could afford a maximum of ten rejections per article via the regular mail, before one was accepted for publication, you can now afford hundreds of rejections via E mail.
Boghos L. Artinian